Hi,
We've created a custom board with the RP2040 and now we ran into problems running code. I've looked at other threads and tried applying what has been suggested such as lowering clock and changing bootloader, without any luck. I've duplicated my tries on a Pico_W and it works on the pico.
I can get a connection to the RP2040 over SWD, and load code into it. But the code doesn't seem to run on our custom board. The test code I'm currently running drives gpio 14 high and low and prints Hello World twice over uart. The code is inserted below.
Some problems with the board design;
- 3.3v is too high. When running from 12v source, we get 3.7v (and 5v is 5v). When running from USB, we get 3.6v (5v is dropped to 4.5v). Sadly I don't have a new resistor to fix this atm. Other voltages are perfectly on the spot.
- USB does not work as intended. It was routed to a hub to then distribute USB over the board. But since I got SWD working I have been focusing on getting code to work over SWD.
Tried both setting set(PICO_DEFAULT_BINARY_TYPE no_flash) and set(PICO_DEFAULT_BINARY_TYPE no_flash) without success.
SWD Logs when loading code onto RP2040SWD Logs when debbigng with SWD
Termnial 1Terminal 2Logs when using minicom to listen to serial0Changes to board header
I've set up a custom board header, with these settings changed. I've moved around the uart values to see if it makes a difference, to no avail.CodeFlash: W25Q32JVSS
Crystal: Shenzhen SCTF Elec S3D12.000000B20F30T
Attached you will find schematics for: RP2040, USB-CONNECTION + PD (J3 is incoming USB), USB-HUB
We've created a custom board with the RP2040 and now we ran into problems running code. I've looked at other threads and tried applying what has been suggested such as lowering clock and changing bootloader, without any luck. I've duplicated my tries on a Pico_W and it works on the pico.
I can get a connection to the RP2040 over SWD, and load code into it. But the code doesn't seem to run on our custom board. The test code I'm currently running drives gpio 14 high and low and prints Hello World twice over uart. The code is inserted below.
Some problems with the board design;
- 3.3v is too high. When running from 12v source, we get 3.7v (and 5v is 5v). When running from USB, we get 3.6v (5v is dropped to 4.5v). Sadly I don't have a new resistor to fix this atm. Other voltages are perfectly on the spot.
- USB does not work as intended. It was routed to a hub to then distribute USB over the board. But since I got SWD working I have been focusing on getting code to work over SWD.
Tried both setting set(PICO_DEFAULT_BINARY_TYPE no_flash) and set(PICO_DEFAULT_BINARY_TYPE no_flash) without success.
SWD Logs when loading code onto RP2040
Code:
openocd -f interface/raspberrypi-swd.cfg -f target/rp2040.cfg -c "program serial/hello_serial.elf verify reset exit"Open On-Chip Debugger 0.12.0-g3e301b3 (2024-07-29-18:50)Licensed under GNU GPL v2For bug reports, read http://openocd.org/doc/doxygen/bugs.htmlWarn : TMS/SWDIO moved to GPIO 8 (pin 24). Check the wiring please!adapter speed: 5000 kHzInfo : Hardware thread awareness createdInfo : Hardware thread awareness createdInfo : BCM2835 GPIO JTAG/SWD bitbang driverInfo : clock speed 5000 kHzInfo : SWD DPIDR 0x0bc12477, DLPIDR 0x00000001Info : SWD DPIDR 0x0bc12477, DLPIDR 0x10000001Info : [rp2040.core0] Cortex-M0+ r0p1 processor detectedInfo : [rp2040.core0] target has 4 breakpoints, 2 watchpointsInfo : [rp2040.core1] Cortex-M0+ r0p1 processor detectedInfo : [rp2040.core1] target has 4 breakpoints, 2 watchpointsInfo : starting gdb server for rp2040.core0 on 3333Info : Listening on port 3333 for gdb connections[rp2040.core0] halted due to debug-request, current mode: Thread xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00[rp2040.core1] halted due to debug-request, current mode: Thread xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00** Programming Started **Info : Found flash device 'win w25q32fv/jv' (ID 0x001640ef)Info : RP2040 B0 Flash Probe: 4194304 bytes @0x10000000, in 64 sectorsInfo : Padding image section 1 at 0x1000272c with 212 bytes (bank write end alignment)Warn : Adding extra erase range, 0x10002800 .. 0x1000ffff** Programming Finished **** Verify Started **** Verified OK **** Resetting Target **shutdown command invoked
Termnial 1
Code:
x@x:~/pico/pico-examples/build $ openocd -f interface/raspberrypi-swd.cfg -f target/rp2040.cfgOpen On-Chip Debugger 0.12.0-g3e301b3 (2024-07-29-18:50)Licensed under GNU GPL v2For bug reports, read http://openocd.org/doc/doxygen/bugs.htmlWarn : TMS/SWDIO moved to GPIO 8 (pin 24). Check the wiring please!adapter speed: 5000 kHzInfo : Hardware thread awareness createdInfo : Hardware thread awareness createdInfo : Listening on port 6666 for tcl connectionsInfo : Listening on port 4444 for telnet connectionsInfo : BCM2835 GPIO JTAG/SWD bitbang driverInfo : clock speed 5000 kHzInfo : SWD DPIDR 0x0bc12477, DLPIDR 0x00000001Info : SWD DPIDR 0x0bc12477, DLPIDR 0x10000001Info : [rp2040.core0] Cortex-M0+ r0p1 processor detectedInfo : [rp2040.core0] target has 4 breakpoints, 2 watchpointsInfo : [rp2040.core1] Cortex-M0+ r0p1 processor detectedInfo : [rp2040.core1] target has 4 breakpoints, 2 watchpointsInfo : starting gdb server for rp2040.core0 on 3333Info : Listening on port 3333 for gdb connectionsInfo : accepting 'gdb' connection on tcp/3333Info : Found flash device 'win w25q32fv/jv' (ID 0x001640ef)Info : RP2040 B0 Flash Probe: 4194304 bytes @0x10000000, in 64 sectorsInfo : New GDB Connection: 1, Target rp2040.core0, state: haltedWarn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333"Info : SWD DPIDR 0x0bc12477, DLPIDR 0x00000001Error: Failed to read memory at 0x20042000[rp2040.core0] halted due to breakpoint, current mode: Thread xPSR: 0x21000000 pc: 0x10001ad4 msp: 0x20041fe0[rp2040.core1] halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00[rp2040.core0] halted due to debug-request, current mode: Thread xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00[rp2040.core1] halted due to debug-request, current mode: Thread xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00Info : Padding image section 0 at 0x100056ac with 84 bytes (bank write end alignment)[rp2040.core0] halted due to debug-request, current mode: Thread xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00[rp2040.core1] halted due to debug-request, current mode: Thread xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00[rp2040.core0] halted due to debug-request, current mode: Thread xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00[rp2040.core1] halted due to debug-request, current mode: Thread xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
Code:
x@x:~/pico/pico-examples/build/hello_world/serial $ gdb-multiarch hello_serial.elfGNU gdb (Debian 13.1-3) 13.1Copyright (C) 2023 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.Type "show copying" and "show warranty" for details.This GDB was configured as "aarch64-linux-gnu".Type "show configuration" for configuration details.For bug reporting instructions, please see:<https://www.gnu.org/software/gdb/bugs/>.Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>.For help, type "help".Type "apropos word" to search for commands related to "word"...Reading symbols from hello_serial.elf...(gdb) target remote localhost:3333Remote debugging using localhost:3333warning: multi-threaded target stopped without sending a thread-id, using first non-exited thread0x10001ad4 in clock_configure (clk_index=<optimized out>, src=0, auxsrc=<optimized out>, src_freq=<optimized out>, freq=0) at /home/itos/pico/pico-sdk/src/rp2_common/hardware_clocks/clocks.c:115115 configured_freq[clk_index] = (uint32_t)(((uint64_t) src_freq << 8) / div);(gdb) loadLoading section .boot2, size 0x100 lma 0x10000000Loading section .text, size 0x4468 lma 0x10000100Loading section .rodata, size 0xed0 lma 0x10004568Loading section .binary_info, size 0x30 lma 0x10005438Loading section .data, size 0x244 lma 0x10005468Start address 0x100001e8, load size 22188Transfer rate: 24 KB/sec, 3698 bytes/write.(gdb) monitor reset init[rp2040.core0] halted due to debug-request, current mode: Thread xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00[rp2040.core1] halted due to debug-request, current mode: Thread xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00(gdb) continueContinuing.
Code:
Welcome to minicom 2.8OPTIONS: I18n Port /dev/serial0, 14:51:48Press CTRL-A Z for help on special keysÿ@$0`H0 ¤
I've set up a custom board header, with these settings changed. I've moved around the uart values to see if it makes a difference, to no avail.
Code:
// --- FLASH ---// #define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1#define PICO_BOOT_STAGE2_CHOOSE_GENERIC_03H 1 // DEBUG WHY WE CANT LOAD CODE#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 // DEBUG WHY WE CANT LOAD CODE#ifndef PICO_FLASH_SIZE_BYTES#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024)#endif// The GPIO Pin used to read VBUS to determine if the device is battery powered.#ifndef PICO_VBUS_PIN#define PICO_VBUS_PIN 28 // Original 24#endif// --- UART ---#ifndef PICO_DEFAULT_UART#define PICO_DEFAULT_UART 1 // Tried 0 and different gpio pins, no luck#endif#ifndef PICO_DEFAULT_UART_TX_PIN#define PICO_DEFAULT_UART_TX_PIN 24 // Tried 0 and different gpio pins, no luck#endif#ifndef PICO_DEFAULT_UART_RX_PIN#define PICO_DEFAULT_UART_RX_PIN 25 // Tried 0 and different gpio pins, no luck
Code:
#include <stdio.h>#include "pico/stdlib.h"#include "hardware/gpio.h"#include "pico/binary_info.h"const uint LED_PIN = 14;int main(){ bi_decl(bi_program_description("This is a test binary.")); bi_decl(bi_1pin_with_name(LED_PIN, "On-board LED")); stdio_init_all(); gpio_init(LED_PIN); gpio_set_dir(LED_PIN, GPIO_OUT); while (1) { printf("Hello, world!\n"); gpio_put(LED_PIN, 1); sleep_ms(250); gpio_put(LED_PIN, 0); puts("Hello World\n"); sleep_ms(1000); }}
Crystal: Shenzhen SCTF Elec S3D12.000000B20F30T
Attached you will find schematics for: RP2040, USB-CONNECTION + PD (J3 is incoming USB), USB-HUB
- Image may be NSFW.
Clik here to view.
- Image may be NSFW.
Clik here to view.
- Image may be NSFW.
Clik here to view.
Statistics: Posted by Jesper_ITOS — Tue Jul 30, 2024 1:36 pm