Im trying to compile and load on esp32 simple assembler code:
pin15.S
.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
i compile it with:
xtensa-esp32s3-elf-as -o pin15.o pin15.S
xtensa-esp32s3-elf-ld -T linkerscript2.ld -o pin15.elf pin15.o
where linkerscript2.ld
ENTRY(_start)
MEMORY
{
iram0_0_seg : ORIGIN = 0x40100000, LENGTH = 0x20000 /* Instruction RAM */
dram0_0_seg : ORIGIN = 0x3FFB0000, LENGTH = 0x20000 /* Data RAM */
}
SECTIONS
{
.literal : {
*(.literal)
} > iram0_0_seg
.text : {
*(.text)
*(.text.*)
} > iram0_0_seg
.data : {
*(.data)
*(.data.*)
} > dram0_0_seg
.bss : {
*(.bss)
*(.bss.*)
} > dram0_0_seg
}
Then add proper header:
esptool.py --chip esp32s3 elf2image pin15.elf ` `
Then write to esp32-s3:
esptool.py --chip esp32-s3 --port /dev/ttyACM0 --baud 115200 write_flash 0x10000 pin15.bin
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=40080000 size=00044h ( 68) load
E (116) esp_image: Segment 0 0x40080000-0x40080044 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
blurrpp314 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.