diff --git a/docs/Targets.md b/docs/Targets.md index c9c5d7a4f..21fe6b5b9 100644 --- a/docs/Targets.md +++ b/docs/Targets.md @@ -2019,9 +2019,34 @@ Note: This also works on Mac OS, but `objcopy` does not exist. Install with `bre ## Renesas RX65N -Tested on the RX65N Target Board that includes an onboard E2 Lite emulator. +Tested on the: +* RX65N-2MB-Starter-Kit-Plus +* RX65N Target Board (RTK5RX65N0C00000BR) (includes onboard E2 Lite emulator) -Default UART Serial output on PC3 via PMOD1-IO0 at Pin 9. This requires an external TTL UART to USB adapter. This feaure is enabled with `DEBUG_UART=1`. +Both include an E2 Lite Emulator. + +### Renesas Console + +Console output is supported with `DEBUG_UART=1`. + +RSK+: +This board includes a USB to Serial port that uses SCI8 and PJ1/PJ2. +This is the wolfBoot HAL default for RX65N. + +RX65N target board: + +Can route UART Serial output to PC3 via PMOD1-IO0 at Pin 9. +This requires an external TTL UART to USB adapter. +You will need to set `CFLAGS_EXTRA+="-DDEBUG_UART_SCI=3"` in .config. +In the renesas-rx.c uart_init these port mode and port function select settings are needed: + +```c +/* Configure PC3/PC2 for UART */ +PORT_PMR(0xC) |= ((1 << 2) | (1 << 3)); +/* SCI Function Select = 0xA (UART) */ +MPC_PFS(0xC2) = 0xA; /* PC2-RXD5 */ +MPC_PFS(0xC3) = 0xA; /* PC3-TXD5 */ +``` Example Boot Output (with DEBUG_UART=1): @@ -2052,6 +2077,8 @@ Current Firmware Version: 1 Hit any key to call wolfBoot_success the firmware. ``` +### Renesas Flash Layout + Default Onboard Flash Memory Layout (2MB) (32KB sector): | Description | Address | Size | @@ -2062,6 +2089,9 @@ Default Onboard Flash Memory Layout (2MB) (32KB sector): | Swap | 0xFFFE0000 | 0x00010000 ( 64 KB) | | wolfBoot | 0xFFFF0000 | 0x00010000 ( 64 KB) | + +### Renesas Data Endianess + To switch RX parts to big endian data use: ```sh @@ -2072,7 +2102,7 @@ OR rfp-cli -if fine -t e2l -device RX65x -auth id FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -write32 0xFE7F5D00 0xFFFFFFFF ``` -## Building Renesas RX65N +### Building Renesas RX65N Building RX wolfBoot requires the RX-ELF compiler. Please Download and install the Renesas RX GCC toolchain: https://llvm-gcc-renesas.com/rx-download-toolchains/ @@ -2093,11 +2123,9 @@ With RX GCC path or or custom cross compiler directly: OR `make RX_GCC_PATH="~/toolchains/gcc_8.3.0.202311_rx_elf"` - TSIP: To enable TSIP use `make PKA=1`. See [docs/Renesas.md](docs/Renesas.md) for details. - -## Flashing Renesas RX65N +### Flashing Renesas RX65N Download the Renesas Flashing Tool: https://www.renesas.com/us/en/software-tool/renesas-flash-programmer-programming-gui Download the Renesas E2 Lite Linux Driver: https://www.renesas.com/us/en/document/swo/e2-emulator-e2-emulator-lite-linux-driver?r=488806 @@ -2122,42 +2150,10 @@ sudo cp 99-renesas-emu.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules ``` -## Debugging Renesas RX65N - -### Debugging Renesas RX65N in e2Studio: +### Debugging Renesas RX65N Create a new "Renesas Debug" project. Choose the "E2 Lite" emulator and the built `wolfboot.elf`. After project is created open the "Debug Configuration" and change the debugger interface from "JTAG" to "FINE". Run debug and it will stop in the "reset" code in `boot_renesas_start.S`. If using Big Endian change endianess mode in "Debugger -> Debug Tool Settings -> Memory Endian -> Big Endian". -### Debugging Renesas RX65N in terminal: - -Requirements: -* `e2-server-gdb`: Included with e2Studio -* `rx-elf-gdb`: Included with e2Studio or rx-elf toolchain. - -Note: On Ubuntu 22 `rx-elf-gdb` requires ncurses5 (use `apt-get install libncurses5`). -Note: The GDB server is inside an Eclipse plugin "com.renesas.platform_1733799057.jar" and will not be extrated until first used in e2Studio. - -```sh -pushd ~/.eclipse/com.renesas.platform_1733799057/DebugComp/RX/ -./e2-server-gdb -g E2LITE -t R5F565NE -uConnectionTimeout=0 -uClockSrcHoco= 1 -uAllowClockSourceInternal= 1 -uUseFine= 1 -uFineBaudRate= 1.50 -w 1 -z 0 -uRegisterSetting= 0 -uModePin= 0 -uChangeStartupBank= 0 -uStartupBank= 0 -uDebugMode= 0 -uExecuteProgram= 0 -uIdCode= FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -uresetOnReload= 1 -n 0 -uWorkRamAddress= 1000 -uverifyOnWritingMemory= 0 -uProgReWriteIRom= 0 -uProgReWriteDFlash= 0 -uhookWorkRamAddr= 0x3fdd0 -uhookWorkRamSize= 0x230 -uOSRestriction= 0 -l -uCore="SINGLE_CORE|enabled|1|main" -uSyncMode=async -uFirstGDB=main --english --gdbVersion=7.2 -``` - -Capture the "GDB: ######" port number and replace in GDB client command below. - -In another console from the wolfBoot directory: - -```sh -rx-elf-gdb -rx-force-v2 -set breakpoint always-inserted on -symbol-file wolfboot.elf -inferior 1 -target extended-remote-rx localhost:###### -monitor set_target,R5F565NE -monitor reset -b main -c -``` - ## Renesas RX72N @@ -2216,7 +2212,7 @@ OR rfp-cli -if fine -t e2l -device RX72x -auth id FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -write32 0xFE7F5D00 0xFFFFFFFF ``` -## Building Renesas RX72N +### Building Renesas RX72N Building RX wolfBoot requires the RX-ELF compiler. Please Download and install the Renesas RX GCC toolchain: https://llvm-gcc-renesas.com/rx-download-toolchains/ @@ -2240,7 +2236,7 @@ OR TSIP: To enable TSIP use `make PKA=1`. See [docs/Renesas.md](docs/Renesas.md) for details. -## Flashing Renesas RX72N +### Flashing Renesas RX72N Download the Renesas Flashing Tool: https://www.renesas.com/us/en/software-tool/renesas-flash-programmer-programming-gui Download the Renesas E2 Lite Linux Driver: https://www.renesas.com/us/en/document/swo/e2-emulator-e2-emulator-lite-linux-driver?r=488806 diff --git a/hal/renesas-rx.c b/hal/renesas-rx.c index 8a2dcde63..0cb3fe70f 100644 --- a/hal/renesas-rx.c +++ b/hal/renesas-rx.c @@ -84,8 +84,8 @@ void hal_delay_us(uint32_t us) /* SCI2: TXD2/PC13, RXD2/PC12 */ #define DEBUG_UART_SCI 2 #else - /* Use SCI5 TXD5/PC3, RXD5/PC5 */ - #define DEBUG_UART_SCI 5 + /* SCI8: TXD8/PJ2, RXD8/PJ1 */ + #define DEBUG_UART_SCI 8 #endif #endif #ifndef DEBUG_BAUD_RATE @@ -95,9 +95,16 @@ void hal_delay_us(uint32_t us) void uart_init(void) { /* Release SCI module stop (clear bit) */ - /* bit 31=SCI0, 30=SCI1, 29=SCI2, 28=SCI3, 27=SCI4, 26=SCI5, 25=SCI6, 24=SCI7 */ PROTECT_OFF(); +#if DEBUG_UART_SCI >= 0 && DEBUG_UART_SCI <= 7 + /* bit 31=SCI0, 30=SCI1, 29=SCI2, 28=SCI3, 27=SCI4, 26=SCI5, 25=SCI6, 24=SCI7 */ SYS_MSTPCRB &= ~(1 << (31-DEBUG_UART_SCI)); +#elif DEBUG_UART_SCI >= 8 && DEBUG_UART_SCI <= 11 + /* bit 27=SCI8, 26=SCI9, 25=SCI10, 24=SCI11 */ + SYS_MSTPCRC &= ~(1 << (27-(DEBUG_UART_SCI-8))); +#else + #error SCI module stop not known +#endif PROTECT_ON(); /* Disable RX/TX */ @@ -107,8 +114,8 @@ void uart_init(void) /* Configure P13/P12 for UART */ PORT_PMR(0x1) |= ((1 << 2) | (1 << 3)); #else - /* Configure PC3/PC2 for UART */ - PORT_PMR(0xC) |= ((1 << 2) | (1 << 3)); + /* Configure PJ1/PJ2 for UART */ + PORT_PMR(0x12) |= ((1 << 1) | (1 << 2)); #endif /* Disable MPC Write Protect for PFS */ @@ -121,8 +128,8 @@ void uart_init(void) MPC_PFS(0xA) = 0xA; /* P12-RXD2 */ MPC_PFS(0xB) = 0xA; /* P13-TXD2 */ #else - MPC_PFS(0xC2) = 0xA; /* PC2-RXD5 */ - MPC_PFS(0xC3) = 0xA; /* PC3-TXD5 */ + MPC_PFS(0xF1) = 0xA; /* PJ1-RXD8 */ + MPC_PFS(0xF2) = 0xA; /* PJ2-TXD8 */ #endif /* Enable MPC Write Protect for PFS */ diff --git a/src/spi_flash.c b/src/spi_flash.c index 6c0ea9873..810154c07 100644 --- a/src/spi_flash.c +++ b/src/spi_flash.c @@ -171,15 +171,15 @@ static int RAMFUNCTION spi_flash_write_sb(uint32_t address, const void *data, in uint16_t spi_flash_probe(void) { - uint8_t manuf, product, b0; + uint8_t manuf, product, notused; int i; spi_init(0,0); wait_busy(); spi_cs_on(SPI_CS_PIO_BASE, SPI_CS_FLASH); spi_write(MDID); - b0 = spi_read(); - - write_address(0); + notused = spi_read(); + spi_write(0); /* ADDR=0 */ + notused = spi_read(); spi_write(0xFF); manuf = spi_read(); spi_write(0xFF); @@ -198,8 +198,10 @@ uint16_t spi_flash_probe(void) spi_read(); spi_cs_off(SPI_CS_PIO_BASE, SPI_CS_FLASH); #endif + wolfBoot_printf("SPI Probe: Manuf 0x%x, Product 0x%x\n", manuf, product); - return (uint16_t)(manuf << 8 | product); + + return (uint16_t)(manuf << 8) | (uint16_t)product; }