Skip to content

Commit

Permalink
flasher_stub: Build against recent SDKs, new ELF image API
Browse files Browse the repository at this point in the history
  • Loading branch information
projectgus committed Aug 30, 2016
1 parent c6446b9 commit baed502
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
6 changes: 6 additions & 0 deletions esptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,12 @@ def __init__(self, name):
with open(self.name, 'rb') as f:
self._read_elf_file(f)

def get_section(self, section_name):
for s in self.sections:
if s.name == section_name:
return s
raise ValueError("No section %s in ELF file" % section_name)

def _read_elf_file(self, f):
# read the ELF file header
LEN_FILE_HEADER = 0x34
Expand Down
2 changes: 1 addition & 1 deletion flasher_stub/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ $(BUILD_DIR):

$(STUB_ELF): $(STUB) $(LIBS) | $(BUILD_DIR)
@echo " CC $^ -> $@"
$(Q) $(CROSS)gcc -I$(SDK_DIR) -std=c99 -Wall -Werror -Os \
$(Q) $(CROSS)gcc -I$(SDK_DIR) -I$(SDK_DIR)/include -L$(SDK_DIR)/ld -std=c99 -Wall -Werror -Os \
-mtext-section-literals -mlongcalls -nostdlib -fno-builtin \
-Wl,-static -Tstub.ld -o $@ $^

Expand Down
2 changes: 1 addition & 1 deletion flasher_stub/rom_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#ifndef ROM_FUNCTIONS_H_
#define ROM_FUNCTIONS_H_

#include <inttypes.h>
#include <c_types.h>

int uart_rx_one_char(uint8_t *ch);
uint8_t uart_rx_one_char_block();
Expand Down
2 changes: 1 addition & 1 deletion flasher_stub/slip.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#ifndef SLIP_H_
#define SLIP_H_

#include <inttypes.h>
#include <c_types.h>

void SLIP_send(const void *pkt, uint32_t size);
uint32_t SLIP_recv(void *pkt, uint32_t max_len);
Expand Down
20 changes: 11 additions & 9 deletions flasher_stub/wrap_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@
e = esptool.ELFFile(sys.argv[1])
entry = 'stub_main'

params_section = e.get_section('.params')
code_section = e.get_section('.code')
data_section = e.get_section('.data')
stub = {
'params_start': e.get_symbol_addr('_params_start'),
'code': e.load_section('.code'),
'code_start': e.get_symbol_addr('_code_start'),
'entry': e.get_symbol_addr(entry),
'params_start': params_section.addr,
'code': code_section.data,
'code_start': code_section.addr,
'entry': e.entrypoint,
}
data = e.load_section('.data')
if len(data) > 0:
stub['data'] = data
stub['data_start'] = e.get_symbol_addr('_data_start')
params_len = e.get_symbol_addr('_params_end') - stub['params_start']
if len(data_section.data) > 0:
stub['data'] = data_section.data
stub['data_start'] = data_section.addr
params_len = len(params_section.data)
if params_len % 4 != 0:
raise FatalError('Params must be dwords')
stub['num_params'] = params_len / 4
Expand Down

0 comments on commit baed502

Please sign in to comment.