Skip to content

Commit cca92dd

Browse files
committed
Merge branch 'master' of github.com:neotron-compute/Neotron-OS
2 parents 290b72c + b832b7d commit cca92dd

File tree

3 files changed

+176
-8
lines changed

3 files changed

+176
-8
lines changed

.cargo/config

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
[target.thumbv7em-none-eabihf]
22
runner = 'arm-none-eabi-gdb --command=gdb.cfg -w'
3-
rustflags = [
4-
"-C", "link-arg=-Tneotron-os-26k.ld",
5-
]
63

74
[build]
85
target = "thumbv7em-none-eabihf"

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,38 @@ This OS is a work in progress. We intend to support:
1414
* [ ] Basic networking
1515
* [ ] Music playback
1616
* [ ] Various keyboard layouts
17+
* [ ] Ethernet / WiFi networking
1718

18-
## Build Instructions
19+
## Build instructions
20+
21+
Your board will need an appropriate Neotron BIOS installed, and you need to have OpenOCD running for your particular board. You also need to set the linker
22+
arguments so you link the binary to suit the memory available on your system.
23+
24+
### Build Instructions for the Neotron 340ST
25+
26+
```
27+
$ git clone https://github.com/neotron-compute/Neotron-OS.git
28+
$ cd Neotron-OS
29+
$ git submodule update --init
30+
$ RUSTFLAGS="-C link-arg=-Tneotron-os-256k.ld" cargo run --release
31+
```
32+
33+
### Build Instructions for the Neotron 32
1934

2035
```
2136
$ git clone https://github.com/neotron-compute/Neotron-OS.git
2237
$ cd Neotron-OS
2338
$ git submodule update --init
24-
$ nano ./Cargo.toml # Edit to use appropriate linker script
25-
$ cargo build --release
26-
$ cargo run --release # Fires up GDB to flash the board
39+
$ RUSTFLAGS="-C link-arg=-Tneotron-os-26k.ld" cargo run --release
2740
```
2841

42+
TODO: Think of a better way of setting the memory limits for a particular OS build.
43+
2944
## Changelog
3045

3146
### Unreleased Changes ([Source](https://github.com/neotron-compute/Neotron-OS/tree/master))
3247

33-
* Basic UART hello on start-up
48+
* Basic UART hello on start-up on the Neotron 32 and Neotron 340ST
3449

3550
## Licence
3651

neotron-os-256k.ld

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/* # Developer notes
2+
3+
- Symbols that start with a double underscore (__) are considered "private"
4+
5+
- Symbols that start with a single underscore (_) are considered "semi-public"; they can be
6+
overridden in a user linker script, but should not be referred from user code (e.g. `extern "C" {
7+
static mut __sbss }`).
8+
9+
- `EXTERN` forces the linker to keep a symbol in the final binary. We use this to make sure a
10+
symbol if not dropped if it appears in or near the front of the linker arguments and "it's not
11+
needed" by any of the preceding objects (linker arguments)
12+
13+
- `PROVIDE` is used to provide default values that can be overridden by a user linker script
14+
15+
- On alignment: it's important for correctness that the VMA boundaries of both .bss and .data *and*
16+
the LMA of .data are all 4-byte aligned. These alignments are assumed by the RAM initialization
17+
routine. There's also a second benefit: 4-byte aligned boundaries means that you won't see
18+
"Address (..) is out of bounds" in the disassembly produced by `objdump`.
19+
*/
20+
21+
/* Provides information about the memory layout of the device */
22+
MEMORY
23+
{
24+
/* The BIOS gets the first 512 KiB of Flash, leaving 512 KiB for the OS */
25+
FLASH (rx) : ORIGIN = 0x08080000, LENGTH = 512K
26+
/* The BIOS gets the top 64 KiB of SRAM (including the Stack), leaving 256 KiB for the OS
27+
(at 0x2000_0000 to 0x2003_FFFF). The RAM is actually split into three banks, but we can
28+
largely ignore that.
29+
*/
30+
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256K
31+
/* The SDRAM holds the LCD framebuffers */
32+
}
33+
34+
/* # Entry point = what the BIOS calls to start the OS */
35+
ENTRY(entry_point);
36+
EXTERN(__RESET_VECTOR);
37+
38+
/* # Sections */
39+
SECTIONS
40+
{
41+
42+
/* ## Sections in FLASH */
43+
.entry_point ORIGIN(FLASH) :
44+
{
45+
KEEP(*(.entry_point))
46+
} > FLASH
47+
48+
PROVIDE(_stext = ADDR(.entry_point) + SIZEOF(.entry_point));
49+
50+
/* ### .text */
51+
.text _stext :
52+
{
53+
*(.text .text.*);
54+
*(.HardFaultTrampoline);
55+
*(.HardFault.*);
56+
} > FLASH
57+
58+
/* ### .rodata */
59+
.rodata : ALIGN(4)
60+
{
61+
*(.rodata .rodata.*);
62+
63+
/* 4-byte align the end (VMA) of this section.
64+
This is required by LLD to ensure the LMA of the following .data
65+
section will have the correct alignment. */
66+
. = ALIGN(4);
67+
} > FLASH
68+
69+
/* ## Sections in RAM */
70+
/* ### .data */
71+
.data : ALIGN(4)
72+
{
73+
. = ALIGN(4);
74+
__sdata = .;
75+
*(.data .data.*);
76+
. = ALIGN(4); /* 4-byte align the end (VMA) of this section */
77+
__edata = .;
78+
} > RAM AT > FLASH
79+
80+
/* LMA of .data */
81+
__sidata = LOADADDR(.data);
82+
83+
/* ### .bss */
84+
.bss : ALIGN(4)
85+
{
86+
. = ALIGN(4);
87+
__sbss = .;
88+
*(.bss .bss.*);
89+
. = ALIGN(4); /* 4-byte align the end (VMA) of this section */
90+
__ebss = .;
91+
} > RAM
92+
93+
/* ### .uninit */
94+
.uninit (NOLOAD) : ALIGN(4)
95+
{
96+
. = ALIGN(4);
97+
*(.uninit .uninit.*);
98+
. = ALIGN(4);
99+
} > RAM
100+
101+
/* Place the heap right after `.uninit` */
102+
. = ALIGN(4);
103+
__sheap = .;
104+
105+
/* ## .got */
106+
/* Dynamic relocations are unsupported. This section is only used to detect relocatable code in
107+
the input files and raise an error if relocatable code is found */
108+
.got (NOLOAD) :
109+
{
110+
KEEP(*(.got .got.*));
111+
}
112+
113+
/* ## Discarded sections */
114+
/DISCARD/ :
115+
{
116+
/* Unused exception related info that only wastes space */
117+
*(.ARM.exidx);
118+
*(.ARM.exidx.*);
119+
*(.ARM.extab.*);
120+
}
121+
}
122+
123+
/* Do not exceed this mark in the error messages below | */
124+
/* # Alignment checks */
125+
ASSERT(ORIGIN(FLASH) % 4 == 0, "
126+
ERROR(cortex-m-rt): the start of the FLASH region must be 4-byte aligned");
127+
128+
ASSERT(ORIGIN(RAM) % 4 == 0, "
129+
ERROR(cortex-m-rt): the start of the RAM region must be 4-byte aligned");
130+
131+
ASSERT(__sdata % 4 == 0 && __edata % 4 == 0, "
132+
BUG(cortex-m-rt): .data is not 4-byte aligned");
133+
134+
ASSERT(__sidata % 4 == 0, "
135+
BUG(cortex-m-rt): the LMA of .data is not 4-byte aligned");
136+
137+
ASSERT(__sbss % 4 == 0 && __ebss % 4 == 0, "
138+
BUG(cortex-m-rt): .bss is not 4-byte aligned");
139+
140+
ASSERT(__sheap % 4 == 0, "
141+
BUG(cortex-m-rt): start of .heap is not 4-byte aligned");
142+
143+
/* # Position checks */
144+
145+
/* ## .text */
146+
ASSERT(_stext + SIZEOF(.text) < ORIGIN(FLASH) + LENGTH(FLASH), "
147+
ERROR(cortex-m-rt): The .text section must be placed inside the FLASH memory.
148+
Set _stext to an address smaller than 'ORIGIN(FLASH) + LENGTH(FLASH)'");
149+
150+
/* # Other checks */
151+
ASSERT(SIZEOF(.got) == 0, "
152+
ERROR(cortex-m-rt): .got section detected in the input object files
153+
Dynamic relocations are not supported. If you are linking to C code compiled using
154+
the 'cc' crate then modify your build script to compile the C code _without_
155+
the -fPIC flag. See the documentation of the `cc::Build.pic` method for details.");
156+
/* Do not exceed this mark in the error messages above | */

0 commit comments

Comments
 (0)