Loading assembler program on esp32-s3
Posted: Thu Aug 15, 2024 2:42 pm
Hi. Im trying to compile and load on esp32 simple assembler code:
pin15.S
i compile it with:
where linkerscript2.ld
Then add proper header:
Then write to esp32-s3:
On /dev/ttyACM0 i get:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x403cdd11
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3810,len:0x1798
load:0x403c9700,len:0x4
load:0x403c9704,len:0xcbc
load:0x403cc700,len:0x2d98
entry 0x403c9914
I (31) boot: ESP-IDF v5.2-dirty 2nd stage bootloader
I (31) boot: compile time Aug 5 2024 03:46:49
I (31) boot: Multicore bootloader
I (35) boot: chip revision: v0.2
I (38) boot.esp32s3: Boot SPI Speed : 80MHz
I (43) boot.esp32s3: SPI Mode : DIO
I (48) boot.esp32s3: SPI Flash Size : 2MB
I (53) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (62) boot: ## Label Usage Type ST Offset Length
I (69) boot: 0 nvs WiFi data 01 02 00009000 00005000
I (76) boot: 1 otadata OTA data 01 00 0000e000 00002000
I (84) boot: 2 app0 factory app 00 00 00010000 00140000
I (91) boot: 3 spiffs Unknown data 01 82 00150000 000a0000
I (99) boot: End of partition table
I (103) boot: Defaulting to factory image
I (108) esp_image: segment 0: paddr=00010020 vaddr=400c0000 size=00010h ( 16) load
E (116) esp_image: Segment 0 0x400c0000-0x400c0010 invalid: bad load address range
E (124) boot: Factory app partition is not bootable
E (130) boot: No bootable app partitions in the partition table
Im trying to understand where is problem. Maybe i should prepare another partition table an write it
pin15.S
- [code]
- .section .text
- .global _start
- _start:
- movi a2, 0x3FF44000
- movi a3, 1 << 15
- s32i a3, a2, 0x4 # Set output bit for GPIO 15
- loop:
- movi a2, 0x3FF44000
- movi a3, 1 << 15
- s32i a3, a2, 0x4
- call0 delay
- movi a2, 0x3FF44000 # GPIO base address
- movi a3, 1 << 15 # Mask for GPIO 15
- s32i a3, a2, 0x8 # Clear output bit for GPIO 15
- call0 delay
- j loop
- delay:
- movi a1, 0x3FFFFF
- delay_loop:
- addi a1, a1, -1
- bnez a1, delay_loop
- ret
- [/code]
- xtensa-esp32s3-elf-as -o pin15.o pin15.S
- xtensa-esp32s3-elf-ld -T linkerscript2.ld -o pin15.elf pin15.o
- ENTRY(_start)
- SECTIONS
- {
- . = 0x400C0000; // i tried many addresses like 0x40080000 etc. with similar problem
- .literal : {
- *(.literal)
- }
- . = 0x400C00F0;
- .text : {
- *(.text)
- *(.text.*)
- }
- . = 0x3FFB0000;
- .data : {
- *(.data)
- *(.data.*)
- }
- .bss : {
- *(.bss)
- *(.bss.*)
- }
- }
- esptool.py --chip esp32s3 elf2image pin15.elf
- esptool.py --chip esp32-s3 --port /dev/ttyACM0 --baud 115200 write_flash 0x10000 pin15.bin
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x403cdd11
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3810,len:0x1798
load:0x403c9700,len:0x4
load:0x403c9704,len:0xcbc
load:0x403cc700,len:0x2d98
entry 0x403c9914
I (31) boot: ESP-IDF v5.2-dirty 2nd stage bootloader
I (31) boot: compile time Aug 5 2024 03:46:49
I (31) boot: Multicore bootloader
I (35) boot: chip revision: v0.2
I (38) boot.esp32s3: Boot SPI Speed : 80MHz
I (43) boot.esp32s3: SPI Mode : DIO
I (48) boot.esp32s3: SPI Flash Size : 2MB
I (53) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (62) boot: ## Label Usage Type ST Offset Length
I (69) boot: 0 nvs WiFi data 01 02 00009000 00005000
I (76) boot: 1 otadata OTA data 01 00 0000e000 00002000
I (84) boot: 2 app0 factory app 00 00 00010000 00140000
I (91) boot: 3 spiffs Unknown data 01 82 00150000 000a0000
I (99) boot: End of partition table
I (103) boot: Defaulting to factory image
I (108) esp_image: segment 0: paddr=00010020 vaddr=400c0000 size=00010h ( 16) load
E (116) esp_image: Segment 0 0x400c0000-0x400c0010 invalid: bad load address range
E (124) boot: Factory app partition is not bootable
E (130) boot: No bootable app partitions in the partition table
Im trying to understand where is problem. Maybe i should prepare another partition table an write it