556ac72d1027a44e1c30e16b2803c2540610ebe2
Sinclair Scientific Calculator Emulator alternative software written in Rust
Alternative implementation for Sinclair Scientific calculator board.
Build Instructions
- Install prerequisites as described in the
avr-halREADME (avr-gcc,avr-libc,avrdude,ravedude). - Use
nightly-2024-03-22toolchain. - Run
cargo build --releaseto build the firmware (debug builds won't work for now). - Run
RAVEDUDE_PORT=/dev/ttyUSB0 cargo run --releaseto flash the firmware to a connected board. Ifravedudefails to detect your board, check its documentation at https://crates.io/crates/ravedude. ravedudewill open a console session after flashing where you can interact with the UART console of your board.
License
Floating point support
Error linking when using f64, undefined reference to:
__divdf3
__gedf2
__gtdf2
__ltdf2
__muldf3
__nedf2
__subdf3
Use f32 as f64 are not supported by avr-libc.
Error linking src/float/add.rs:161: more undefined references to 'core::panicking::panic' follow
- Goes away when using
--releasebuilds - https://github.com/rust-lang/compiler-builtins/issues/245
Error multiple definition of '__addsf3'
(.text.avr-libc.fplib+0x2): multiple definition of `__addsf3';
avr-calc/target/avr-atmega328p/release/deps/libcompiler_builtins-ff74a4526ccb7313.rlib(compiler_builtins-ff74a4526ccb7313.compiler_builtins.63915e056af5b1f3-cgu.0.rcgu.o):
.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.108/src/macros.rs:500: first defined here
objdump -t target/avr-atmega328p/release/deps/libcompiler_builtins-ff74a4526ccb7313.rlib | grep __addsf3
00000000 l d .text._ZN17compiler_builtins5float3add8__addsf317h33c25ff7dd1591e8E 00000000 .text._ZN17compiler_builtins5float3add8__addsf317h33c25ff7dd1591e8E
00000000 l d .text.__addsf3 00000000 .text.__addsf3
00000000 g F .text._ZN17compiler_builtins5float3add8__addsf317h33c25ff7dd1591e8E 0000085c .hidden _ZN17compiler_builtins5float3add8__addsf317h33c25ff7dd1591e8E
00000000 g F .text.__addsf3 00000006 .hidden __addsf3
- https://github.com/rust-lang/compiler-builtins/tree/master/compiler-builtins
compiler-builtinsalso implements software floats and this collides withlibmfromavr-lib.- It provides
__adddf3and__addsf3but not__divdf3and others listed above? - The
__addsf3is provided by both libs,avr-libdoes not providef64variants andbuiltinssome operations are missing?
- It provides
- Compiling with no default libraries and just
libc(formem*functions) still does not work as it imports__addsff3:
= note: /usr/bin/avr-ld:
/usr/lib/gcc/avr/9.3.0/../../../../avr/lib/avr5/libc.a(addsf3.o): in function `__addsf3':
(.text.avr-libc.fplib+0x2): multiple definition of `__addsf3';
target/avr-atmega328p/release/deps/libcompiler_builtins-0dbc77ea0d873946.rlib(compiler_builtins-0dbc77ea0d873946.compiler_builtins.88514279ac67cc58-cgu.0.rcgu.o):index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.108/src/macros.rs:500: first defined here
avr-libc
- https://github.com/avrdudes/avr-libc
- Only
f32are implemented: https://github.com/avrdudes/avr-libc/tree/main/libm/fplib
The atmega328p uses libraries from /usr/avr/lib/avr5/ and it contains libm.
libm.a contains all the missing symbols but with sf instead of df.
objdump -t /usr/avr/lib/avr5/libm.a | grep fpsf3single (f32) floatdf3double (f64) float- https://gcc.gnu.org/onlinedocs/gcc-3.4.0/gccint/Soft-float-library-routines.html
float __divsf3 (float a, float b)
double __divdf3 (double a, double b)
Setting "no-default-libraries": true, in avr-specs/avr-atmega328p.json excludes libm, adding -lm and -lc works.
Description
Languages
Rust
100%