Usb Loader Gx Quick Boot

0 views
Skip to first unread message

John

unread,
Aug 3, 2024, 3:50:45 PM8/3/24
to stasisadcou

I'm trying to speed up the arduino zero boot times. I'm using a custom board based on the SAMD21, and using the Arduino IDE for development. I normally upload my code via USB, but I also have an Atmel-ICE programmer.

I checked on an oscilloscope, power on the microcontroller is instant, and although there might be some propagation delay (I use a driver to power a laser) it is in the microseconds range, not 1.7s. Again, I checked on an oscilloscope, and the delay is from power on to first activity on the pins of the SAMD

I think I read that removing the bootloader I might achieve faster (instant??) boot. I followed the advice of the great AloyseTech here ([Solved] Programming a SAMD21 with the ATMEL-ICE from the IDE - Arduino Zero - Arduino Forum) to remove the bootloader of my boards, and program them straight from the programmer, and I have the same boot times if I program it from the IDE using the no bootloader option, if I export the binary from the IDE and flash it with Atmel Studio and if I flash the bootloader, and export the binary and I flash it from Atmel studio without erasing the chip and starting in address 0x2000.

The bootloader if compiled with the double tap functionality should take at least 500ms. If you don't need the double-tap-on-reset-to-stay-in-bootloader feature, you can remove it. You'll have to look for the remaining 1.2 seconds though.

I have a 10uF in the 3.3V (although is not very close to VDDA :S), plus the 1uF in the VDDA/GNDA pair, and one 100nF in one of the VDDIO pins (I didn't know that I needed one on each "pair". The crystal is this one (Crystal), and I added the standard 22p as it appears (as an indication) in the SAMD21 datasheet. Sure, it's quite lacking compared to the Xplained and Zero boards, but Adafruit's Feather has even less and it seems to be working good.

The 1.7sec needed for booting are not an issue. I may have been a bit unclear sorry.
The boot time is around the same for my board. What I as saying is that there are 500ms taken for sure by the bootloader to check if a double tap occurred (see here). The remaining 1.2 sec might be a lot of USB stuff. Have you measured the boot time with or without USB connection? Is there a difference?

Well, there is no USB connections on the board, or any USB-dependant code, it's just a blink sketch. I guess that that doesn't mean that the USB activity that you mention doesn't happen, but I can't see how to make it "not happen".

What puzzles me even more is that I'm generating the binary file for a "with bootloader" board and a "without bootloader" board, and flashing it with atmel studio (offsetting it to 0x2000 for the bootloader version), and both take the same amount of time, although when I plug a development board that has a USB socket, the one with bootloader appears as a com port in windows, and the one without doesn't (so I think that means I managed to get rid of the bootloader).

I actually don't use the Arduino Zero, but rather the Sparkfun SAMD21 dev board. Without the boot loader my sketches do launch instantly, with it they launch in less than a second. I'd venture to guess you have a timing / crystal issue.

I'm not saying I don't have a HW issue somewhere, but the thing is: I CAN start it instantly, if I use Atmel Studio for the development, and don't use the Arduino libraries. I attached the Atmel Studio project in a previous message, if you want to check it. If I use the Arduino IDE, then 1.7 seconds is the fastest I can make it. Regarding adding or removing the bootloader, I think I'm doing correctly, but I might be doing it wrong and not removing it. In any case, I see no differences by adding it or removing it. Sadly, I don't have an official board at hand to check. What puzzles me is that I can start it instantly with a certain code, but not with the IDE. Is not a deal breaker, but I would like to know why. I also understand that my board is custom, and hence what applies to the zero doesn't have to apply to my board.

There's a way to get the SAMD21 to output its clock signals but I haven't been able to make it work. Below is a chunk of code I use to initiate a pulse output on pin 12... you should see a 400Hz pulse with this code if your clocks are working right.

I am using an m0 based "Feather" board from Adafruit in a solar-powered application where we do not want to burn a bunch of power during startup.
I measured the startup delay from application of power to the entry to setup() (signaled by a pin write) as between 1.7-2.2s. I could not figure out where that delay was coming from. I erased the bootloader by unprotecting the bootloader[1] area and erasing the whole chip from within Atmel Studio 7. Even with a simple sketch flashed on, the delay remained.
The issue did not show up with a debugger attached. I assume this was since the board was already powered and had been through one clock start-up sequence, so the OSC32 peripheral was still running or is running by default and the clock was ready instantly.

If you look into the startup.c file for the SAMD core, you'll see that there is code for both an external 32Khz crystal and one for using the internal 32Khz oscillator. By defining the symbol CRYSTALLESS, the internal clock will be used instead, which greatly shortens the startup time. This was done at the project properties level in Atmel Studio 7, under Toolchain -> ARM/GNU C Compiler -> Symbols , and also the same for the ARM/GNU C++ Compiler section, for both the 'ArduinoCore' project and the sketch project.

Of course, there is no need for the core to busy-wait while the clocks are starting up, so a more nuanced approach to bring-up should be totally possible, one where the core clock is switched after it becomes stable or the core is in sleep until that clock is ready.

I'm having the same issue using a raw samd21g18 chip. If I use the arduino libraries (arduino IDE or AS7) I get a 2sec startup delay but if I add CRYSTALLESS to the symbols, startup is immediate (which is great) but...
If I use CRYSTALLESS my USB is not recognized, whereas simply removing this the USB is recognized????
Creating a simple atmel.start project, startup is immediate but I'm not able to test the USB (still relatively new and rely on the arduino framework).

So I've got a raw samd21G18 chip working, even with a bootloader but I can't have a 2 second start delay, it needs to be under 500ms. I'm happy to use CRYSTALLESS as long as I can get windows to recognize the device if using an external crystal is going to take 1-2sec to stabilize?

I disabled windows' "quick boot" feature, then run boot-repair, but it doens't fix the issue (it used to work when windows 8 messed the boot config, but not with windows 8.1). I installed esayBCD on windows and now I see its boot loader, but not grub.I even tried chrooting and grub-installing on /dev/sda, but I don't think that grub is the boot loader loaded at startup.

Your Boot Repair output shows that there's no BIOS/CSM/legacy boot loader installed, so it's unlikely that the screen you're seeing is for that. It's more likely to be the Windows EFI-mode boot manager.

You've taken all the right steps, so it's puzzling why it's not working. Your symptoms, though, are mostly consistent with a computer on which Secure Boot is enabled, so to start with, I recommend you check your firmware's Secure Boot settings. Maybe it got turned back on after you disabled it, or maybe there's something odd about the setting that you overlooked. (OTOH, the fact that you can boot with a rEFInd USB flash drive argues against this possibility. Still, it's worth checking....)

Ok so after about 9 hours of trying to install Lubuntu on my laptop that has Windows 8.1 I have figured everything out except how to have an automatic option between OS's when booting. So, here's what I have learned:

Download Unetbootin selecting the run feature. Once the install is complete start the program. I shouldn't have to say this but we all have these moments so: Make sure your USB is in your computer LOL. Next check that your USB has enough room for what you're doing. Everything I've read says to use an 8GB USB (for Lubuntu) so that's what I did and it took up 0.6GB and I have a hard time believing it needs 7GB to run. However, if your installing Ubuntu, I'd say you probably want to use an entire 8GB USB just to be safe.

Now you need to partition your HDD, if you don't have a partition software MiniTool is a good freeware you can use, and it's what I'm going to describe here and use pics of. So if you need to download that now. The size of your partition drive doesn't need to be big (I used 13GB, 10GB for the operating drive and 3GB for the swap drive). As before with the USB if you're planning to install Ubuntu you'll probably want to allocate more space for the root HDD you choose.

I left the fast boot option ON in the Windows 8.1 and also left the UEFI and Secure boot options on in the BIOS. My setup was Windows 8.1 Pro and Ubuntu 13.10. I also tried Debian 7.3 and it was giving me the same problem until I made the above changes to the BIOS.

The Adafruit Feather SAMD21 takes about two seconds from power being supplied to when setup() starts running. How can I shorten that time so that setup() will run sooner? I measure this time using a power supply and others appear to measure similar times with their eyeballs.

I understand that 328 microcontrollers can be made to boot quicker (almost instantly from a human perspective) using different bootloaders for example, but I haven't found one for the M0 SAMD21 nor another method.

After consulting the datasheet for the SAMD21, I verified that the processor starts immediately once the internal clocks are stable. This happens quickly. The reset vector directs execution to the Arduino bootloader, which certainly spins while waiting for the Arduino programmer to connect. If that does not happen during that delay, the bootloader jumps to the resident application. The delay with no activity is how the bootloader determines that you want to start the application. You can eliminate that by programming the processor using a hardware programmer/debugger, and getting rid of the Arduino bootloader.The hardware programmers also allow source level breakpoint debugging. You just have to learn to use a decent IDE programming environment. A good prgrammer will cost you around $160.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages