Skip to content

Flash programming bugfixes #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Flash programming bugfixes #2

wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 30, 2018

A fix for flash erase, and cherry-picking a fix from @AdamLaurie.

AdamLaurie and others added 4 commits November 30, 2018 10:11
flash_check_erase_and_write() didn't calculate the last page to erase
correctly, because it was written like if the len argument was in
bytes instead of 2-byte words.

This bug lead to pages not being erased properly when downloading a
hex file whose entries span page boundaries.

Signed-off-by: Jonas Norling <jonas.norling@greeneggs.se>
When calling flash_erase_page() with a too high page number it wraps
around and starts erasing bootloader pages. Add a check to avoid that.

Signed-off-by: Jonas Norling <jonas.norling@greeneggs.se>
This fixes a bug that's exposed when plugging in the device in a
Windows 10 host. After enumeration it sends a SET CONTROL LINE STATE
request followed by a SET LINE CODING request. The former has 0 bytes
payload data, which caused the USB device to stall the latter
transaction. This happened because USBCS0_DATA_END was set in
usb_ep0_setup (indicating no data expected for this transaction), and
then again in usb_ep0_flush (indicating no data expected in the _next_
transaction). The bit remained set, causing the MCU to stall the
following OUT transaction.

This didn't cause problems on Linux because it has a different access
pattern.

The fix is to call usb_ep0_flush() only when needed, i.e. when we're
in USB_EP0_DATA_IN state and there is data to send.
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.

2 participants