Skip to content

Commit

Permalink
Merge #3096 #3099
Browse files Browse the repository at this point in the history
3096: Trim zero-length symbol aliases in print_tock_memory_usage r=bradjc a=phil-levis

Some versions of LLVM insert lots of $t and $d symbols; these confuse print_tock_memory_usage's calculation of symbol sizes. This change filters which symbols are considered by only looking at .text symbols that are F (function) or O (object), trimming zero-length symbol aliases.

### Pull Request Overview

This pull request changes print_tock_memory_usage to trim symbols which confuse its size calculations.


### Testing Strategy

This pull request was tested by running the tool under MacOS.


### TODO or Help Wanted




### Documentation Updated

- [x] Updated the relevant files in `/docs`, or no updates are required.

### Formatting

- [x] Ran `make prepush`.


3099: Enable all storage on nRF52840-DK #3098 r=bradjc a=TheConner

### Pull Request Overview

This PR increases the userspace storage of the nRF52840-DK (re #3098) to use all of the available external flash on the board. New flash regions are as follows:

Kernel: 0-0x60000 (384 Kb)
Userspace: 0x60000-0x4000000 (63.625 Mb)
For a total of 64Mb.

### Testing Strategy

I built and installed the kernel on my nRF52740-DK, and used the  [nonvolatile storage test application](https://github.com/tock/libtock-c/tree/master/examples/tests/nonvolatile_storage) to see how much storage is reported. All tests suceeded, and the correct amount of storage (66715648 bytes, 63.625Mb) is reported.


### TODO or Help Wanted

Regarding testing, ideally there would be a test application to ensure all the flash is functioning correctly, instead of only 512 bytes. 

### Documentation Updated

- [x] N/A

### Formatting

- [x] Ran `make prepush`.


Co-authored-by: Philip Levis <pal@cs.stanford.edu>
Co-authored-by: Conner Bradley <bradley@advtech.ca>
  • Loading branch information
3 people committed Jul 21, 2022
3 parents 8f1f17b + 8b1b981 + de7fa4d commit 2c267cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
8 changes: 4 additions & 4 deletions boards/nordic/nrf52840dk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,10 @@ pub unsafe fn main() {
board_kernel,
capsules::nonvolatile_storage_driver::DRIVER_NUM,
mx25r6435f,
0x60000, // Start address for userspace accessible region
0x20000, // Length of userspace accessible region
0, // Start address of kernel region
0x60000, // Length of kernel region
0x60000, // Start address for userspace accessible region
0x3FA0000, // Length of userspace accessible region
0, // Start address of kernel region
0x60000, // Length of kernel region
)
.finalize(components::nv_storage_component_helper!(
capsules::mx25r6435f::MX25R6435F<
Expand Down
16 changes: 11 additions & 5 deletions tools/print_tock_memory_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,15 @@ def process_symbol_line(line):
first try to demangle it; if that fails, use it as is."""
# pylint: disable=line-too-long,anomalous-backslash-in-string
match = re.search(
"^(\S+)\s+\w+\s+\w*\s+\.(text|relocate|sram|stack|app_memory)\s+(\S+)\s+(.+)",
"^(\S+)\s+\w+\s+(\w*)\s+\.(text|relocate|sram|stack|app_memory)\s+(\S+)\s+(.+)",
line,
)
if match != None:
addr = int(match.group(1), 16)
segment = match.group(2)
size = int(match.group(3), 16)
name = match.group(4)
symbol_type = match.group(2)
segment = match.group(3)
size = int(match.group(4), 16)
name = match.group(5)

# Initialized data: part of the flash image, then copied into RAM
# on start. The .data section in normal hosted C.
Expand All @@ -208,6 +209,11 @@ def process_symbol_line(line):

# Code and embedded data.
elif segment == "text":
# Prune symbols that aren't a function or data: these
# confuse calculating symbol lengths, as they are typically
# zero-length aliases for real symbols.
if symbol_type != "F" and symbol_type != "O":
return
match = re.search("\$(((\w+\.\.)+)(\w+))\$", name)
if match != None:
symbol = parse_mangled_name(name)
Expand Down Expand Up @@ -485,7 +491,7 @@ def compute_padding(symbols):
size_sum = size_sum + esize
padding_size = (total_size - esize)
if total_size != esize and total_size != 0:
elements.append((symbol, 0, padding_size, padding_size))
elements.append((esymbol, 0, padding_size, padding_size))
diff = diff + padding_size
return elements

Expand Down

0 comments on commit 2c267cc

Please sign in to comment.