Skip to content
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

rp2040: fix errata RP2040-E5 issue #2991

Merged
merged 3 commits into from
Dec 20, 2022
Merged

rp2040: fix errata RP2040-E5 issue #2991

merged 3 commits into from
Dec 20, 2022

Conversation

@sago35
Copy link
Member Author

sago35 commented Jul 28, 2022

As noted in the comments below, the code in this PR is probably working correctly.
However, I am still not sure.

#3012 (comment)

tinygo flash failed when USB-CDC exchange was executed from another microcontroller with the same USB-HUB.
To be clear, USB Enumeration has failed.

https://github.com/tinygo-org/tinygo/pull/2991 source will allow successful USB Enumeration.
Perhaps a workaround for errata is done.

@sago35
Copy link
Member Author

sago35 commented Sep 17, 2022

RP2040-E5 fix ready for review.
It is difficult to verify that this change has been implemented correctly.
However, as mentioned above, there are cases where it is working well and should be added.

@deadprogram
Copy link
Member

@sago35 just wondering if we should be checking the chip version for this fix, similar to https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c#L27

@sago35
Copy link
Member Author

sago35 commented Dec 20, 2022

@deadprogram version check added.

I checked machine.ChipVersion() with the following code.
The ChipVersion is probably obtained correctly.

pico (B0 chip)

$ tinygo flash --target pico --size short --monitor ./_x/rp2040_version/
   code    data     bss |   flash     ram
  49128    1460    3184 |   50588    4644
Connected to COM48. Press Ctrl-C to exit.
machine.ChipVersion : 01

pico-w (B2 chip)

$ tinygo flash --target pico --size short --monitor ./_x/rp2040_version/
   code    data     bss |   flash     ram
  49128    1460    3184 |   50588    4644
Connected to COM48. Press Ctrl-C to exit.
machine.ChipVersion : 02

test code

package main

import (
	"fmt"
	"machine"
	"time"
)

func main() {
	for {
		fmt.Printf("machine.ChipVersion : %02X\n", machine.ChipVersion())
		time.Sleep(1 * time.Second)
	}
}

The const values were described below.

SYSINFO_BASE
https://github.com/raspberrypi/pico-sdk/blob/2e6142b15b8a75c1227dd3edbe839193b2bf9041/src/rp2040/hardware_regs/include/hardware/regs/addressmap.h#L37

SYSINFO_CHIP_ID_OFFSET
https://github.com/raspberrypi/pico-sdk/blob/2e6142b15b8a75c1227dd3edbe839193b2bf9041/src/rp2040/hardware_regs/include/hardware/regs/sysinfo.h#L17

SYSINFO_CHIP_ID_REVISION_BITS
https://github.com/raspberrypi/pico-sdk/blob/2e6142b15b8a75c1227dd3edbe839193b2bf9041/src/rp2040/hardware_regs/include/hardware/regs/sysinfo.h#L24

SYSINFO_CHIP_ID_REVISION_LSB
https://github.com/raspberrypi/pico-sdk/blob/2e6142b15b8a75c1227dd3edbe839193b2bf9041/src/rp2040/hardware_regs/include/hardware/regs/sysinfo.h#L26

@sago35
Copy link
Member Author

sago35 commented Dec 20, 2022

Sometimes machine_rp2040_enter_bootloader.go fails.
It may be due to CGO, but I am not sure.
Any ideas? @aykevl

https://github.com/tinygo-org/tinygo/blob/rp2040-e5/src/machine/machine_rp2040_enter_bootloader.go

 D:/a/tinygo/tinygo/build/tinygo/bin/tinygo build -size short -o test.hex -target=badger2040          examples/blinky1
# machine
Error: build\tinygo\src\machine\machine_rp2040_enter_bootloader.go:27:1: error: stack nearly exhausted; compilation time may suffer, and crashes due to stack overflow are likely
mingw32-make: *** [makefile:615: smoketest] Error 1
Error: Process completed with exit code 2.

@deadprogram
Copy link
Member

@sago35 that is one of the occasional errors that only occur in the Windows smoke tests. Something is not quite correct, but not sure it can be attributed to the place the error appears. However, not sure on that one.

@deadprogram
Copy link
Member

Thanks for making the requested changes @sago35 now merging.

@deadprogram deadprogram merged commit 6cdc718 into dev Dec 20, 2022
@deadprogram deadprogram deleted the rp2040-e5 branch December 20, 2022 14:53
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