Skip to content

Conversation

@JakubVanek
Copy link
Contributor

@JakubVanek JakubVanek commented Jun 16, 2025

This flashing flow has some advantages:

  • It is more interactive - the long erase command is avoided
  • It seems to be less sensitive to hardware malfunctions. See issue Doesn't detect EV3 under Windows #45 where this mode was used to flash an EV3 brick with what looks like faulty RAM.

As some functions are now called repeatedly, I tried to go through them and eliminate the memory leaks in them.

I have not yet tested this new code myself, so I have created this as a draft PR for now. This is also rebased on top of #46 because I've moved the FLASH_* macros to the funcs.h header.

@JakubVanek
Copy link
Contributor Author

There is something wrong with this and I am not certain what is it. When I flash the 1.09E firmware using this branch, one sector comes out consistently corrupted:

Sector   4: Remote CRC = 689F13E1, local CRC = D3CF1A60 ERR

@JakubVanek
Copy link
Contributor Author

JakubVanek commented Jun 20, 2025

The flashing speed is slightly lower, but it still seems acceptable.

  • Original bulk programming approach: 2 minutes 4 seconds
  • New piecewise programming approach: 2 minutes 24 seconds

@JakubVanek
Copy link
Contributor Author

There is something wrong with this and I am not certain what is it. When I flash the 1.09E firmware using this branch, one sector comes out consistently corrupted:

Sector   4: Remote CRC = 689F13E1, local CRC = D3CF1A60 ERR

Things are getting more weird: even programming the brick using the original code produces the same (mismatching) remote CRC.

@JakubVanek
Copy link
Contributor Author

The CRC issue is not visible when I flash the 1.10E firmware, only when I flash the 1.09E firmware.

@JakubVanek
Copy link
Contributor Author

Whatever the problem with sector 4 is, it is reproduced by flashing the brick via the classic EV3 software app on Windows and so it does not look like a bug in ev3duder.

@JakubVanek JakubVanek force-pushed the feature/piecewise-flash branch from 0180811 to 1688487 Compare June 20, 2025 10:19
@JakubVanek
Copy link
Contributor Author

The code seems to work OK against a real brick after all.

@JakubVanek JakubVanek marked this pull request as ready for review June 20, 2025 10:24
@JakubVanek
Copy link
Contributor Author

JakubVanek commented Jun 20, 2025

I think I know what the problem with sector 4 in firmware 1.09E was. The sector is matching before the brick is first rebooted out of firmware update mode. This would indicate that U-Boot has its environment block there. The available U-Boot sources indicate the same: https://github.com/mindboards/ev3sources/blob/78ebaf5b6f8fe31cc17aa5dce0f8e4916a4fc072/extra/uboot-03.20.00.13/include/configs/da850evm.h#L176

gtminch and others added 2 commits June 21, 2025 02:12
"flash crc" gives the user various ways of comparing the CRC of a file to
the CRC reported by the EV3 bootloader.  Can do that for the full image,
or a group of sectors, or sector-by-sector.
This flashing flow has some advantages:

- It is more interactive - the long erase command is avoided
- It seems to be less sensitive to hardware malfunctions. See issue
  c4ev3#45 where this mode was used
  to flash an EV3 brick with what looks like faulty RAM.

As some functions are now called repeatedly, I tried to go through them
and eliminate the memory leaks in them.
@JakubVanek JakubVanek force-pushed the feature/piecewise-flash branch from 6efb152 to 032cb28 Compare June 21, 2025 00:18
@dlech
Copy link
Contributor

dlech commented Jan 4, 2026

You might find pybricks/pybricks-code#2356 interesting.

I did a bunch of testing today (with Pybricks Code, not ev3duder - but the same ideas) and my conclusion is that the probability of ERR_USBLOOP depends on how long it takes to execute a bootloader command. I would occasionally see that error with a FW_DOWNLOAD_DATA command with a payload size of 384 bytes (This is what is left at the end of a 64KiB page. 65536 % 1018 = 384.)

With a bit of creativity, I was able to avoid commands of that size or smaller and so far haven't seen a ERR_USBLOOP with that approach.

I haven't done anything with CRC yet though. It could be interesting to use that to see what firmware is already on the EV3 and avoid re-flashing identical sectors. Based on the code here, it looks like that suffers from ERR_USBLOOP as well. So I wonder if checksum commands for larger sizes would take longer and avoid the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants