Not my iPhone! (Having chrome preinstalled)
Iād expect something like that too but all examples Iāve seen are/behave the same.
The code to select a port is:
const port = await navigator.serial.requestPort();
Only options that are possible are vid pid filters
Okay I just tried it on my W10 laptop and it seems it will detect live port changes. So itās probably my old W8.1 desktop thats the issue.
AFAIK āChromeā on OSX runs on webkit and not real chromium. Might as well stick with safari
I actually run Firefox on my phone too so I can share the bookmarks across devices. I donāt mind Safari on a phone but not really on the desktop.
So back to the real question ⦠can that code be used to flash from the Cart web site?
If it can definitely flash a .hex
file without issue, thereās no reason (as far as I can see) that it shouldnāt be able to be adapted to work with the FX chip. As I mentioned before, itās just a matter of sending commands to the bootloader - the āknockingā is the difficult bit.
The FX model bootloader (Cathy3K? Iām terrible at keeping track of these bootloader versions) uses a modified version of AVR109 with a few additional commands. Itās documented in a thread somewhere.
Hereās the thread with the extended commands:
I can assist with the Cart side of the project but I am not sure I know enough to do the flashing part.
A session that uploads data to the FX chip might look like:
-
'P'
/80
/0x50
- Enter programming mode -
'B'
/66
/0x42
- Begin block command - <High byte of a page address>
- <Low byte of a page address>
-
'C
/67
/0x43
- Specify that the block is to be written to the FX chip - <A page worth of data to be written to the FX chip>
-
'L'
/76
/0x4C
- Leave programming mode -
'E'
/69
/0x45
- Exit bootloader
At least I presume a āblockā for the FX chip is a page.
I donāt recall how many bytes are in a page though.
I think itās either 256B, 1KB or 4KB.
I could give you a copy of my command-line uploader (written in C++) if itāll help, but I abstracted the commands away so youād have to do a bit of digging to see the full extent of whatās going on.
As for the āknockingā, you have to:
- Connect on the active port with settings of:
- 1200 baud
- A byte size of 8
- No parity bit(s)
- 1 stop bit
- Then close the connection
After which, another port will become available (for Windows itās usually the next numbered COM port) and that will be an open connection to the device in bootloader mode.
I canāt remember who it was that termed this ritual āknockingā, but the idea is that the first connection is like the secret knock that gets you into the masonic lodge of the bootloader.
Hold onto the C++ code ⦠the example JS code is probably much closer to what the end product will look like. If it is doing pretty much what your C++ code is doing, it will make an excellent starting point for someone to use.
But unfortunately, probably not me!
Nicely worded!
Iāve made a few little changes to that avr109 webserial and managed to upload a hex file now (Chrome and Edge). Looks promising
Woohoo!
I cannot wait to see this work.
No real work today?
Iāll see if I can play around with it some more.
Shout out when its time to integrate into the cart site
Another thing to consider is what O/Ss need to be supported. Arduino supports Win, iOS, Linux.
Something built using WebSerial would run on whatever OS supporting browsers would run on.
Apparently it is actually possible to run Chrome on Linux, and it seems that Chromium also runs on Linux.
Do you mean macOS (formerly OS X)? iOS (formerly iPhone OS) is the phone version.
Sorry, yes. I get the Apple systems mixed up. Windows has always been Windows and Linux has always been Linux.
Note that Mozilla have declared that they have no intent to support WebSerial, they consider it to be harmful. Still, according to caniuse.com, the amount of people using a compatible browser (Chrome, Opera, Edge) is a significant chunk, so itāll be useful even if a lot the regulars are on Firefox.
I played a bit more with that WebSerial example and it seems we can forget to have a simple upload button. Each new browser session we need pair/ approve the com port again twice! once for the port that appearswhen a USB enabled game is running on Arduboy) and 2nd for the actual bootloader port. only when both ports are paired / approved we could do an automatic upload. example:
Arduboy is connected to PC and a USB enabled game is running:
- click upload button
- a pop up will appear to connect to Arduboys port.
- select the port and click connect.
- Arduboy is ātrickledā into bootloader mode
- another pop up will appreat to select the bootloader port
- select the port and click connect.
- file can now be uploaded
For the classic Arduboy youāll have to be fast at step 6 as the classic bootloader will only be active for ~8 seconds.
What do you mean by āpop upā here - another browser window or some sort of dialogue. Can we direct that activity to an iFrame or something so it looks OK?
Itāll likely be one of those āthis webpage would like to access your microphoneā sort of pop-ups because access to a serial port is a potential security risk. Odds are itās entirely controlled be the browser and the JavaScript engine canāt even āseeā it due to sandboxing.