soc-hub-fi / headsail-vp

Headsail — Virtual Platform
0 stars 2 forks source link

Alloc example not building for sdram #74

Open vilukissa68 opened 4 days ago

vilukissa68 commented 4 days ago

Trying to run alloc example in headsail-bsp:

cargo run --example alloc -Fsysctrl-rt -Fpanic-sysctrl-uart -Falloc -Fsdram --target riscv32im-unknown-none-elf

fails to build with the following error when compiling headsail-sysctrl-pac:

error[E0599]: no method named `compare_exchange_weak` found for struct `AtomicBool` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/mutex/spin.rs:182:14
    |
180 |           while self
    |  _______________-
181 | |             .lock
182 | |             .compare_exchange_weak(false, true, Ordering::Acquire, Ordering::Relaxed)
    | |             -^^^^^^^^^^^^^^^^^^^^^ method not found in `AtomicBool`
    | |_____________|
    |

error[E0599]: no method named `compare_exchange` found for struct `AtomicBool` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/mutex/spin.rs:242:14
    |
240 |           if self
    |  ____________-
241 | |             .lock
242 | |             .compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed)
    | |             -^^^^^^^^^^^^^^^^ method not found in `AtomicBool`
    | |_____________|
    |

error[E0599]: no method named `compare_exchange` found for struct `core::sync::atomic::AtomicU8` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/once.rs:114:18
    |
112 |               match self
    |  ___________________-
113 | |                 .0
114 | |                 .compare_exchange(old as u8, new as u8, success, failure)
    | |                 -^^^^^^^^^^^^^^^^ method not found in `AtomicU8`
    | |_________________|
    |

error[E0599]: no method named `fetch_add` found for struct `AtomicUsize` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/rwlock.rs:265:31
    |
265 |         let value = self.lock.fetch_add(READER, Ordering::Acquire);
    |                               ^^^^^^^^^ method not found in `AtomicUsize`

error[E0599]: no method named `fetch_sub` found for struct `AtomicUsize` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/rwlock.rs:268:23
    |
268 |             self.lock.fetch_sub(READER, Ordering::Relaxed);
    |                       ^^^^^^^^^ method not found in `AtomicUsize`

error[E0599]: no method named `fetch_sub` found for struct `AtomicUsize` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/rwlock.rs:305:23
    |
305 |             self.lock.fetch_sub(READER, Ordering::Release);
    |                       ^^^^^^^^^ method not found in `AtomicUsize`

error[E0599]: no method named `fetch_sub` found for struct `AtomicUsize` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/rwlock.rs:349:19
    |
349 |         self.lock.fetch_sub(READER, Ordering::Release);
    |                   ^^^^^^^^^ method not found in `AtomicUsize`

error[E0599]: no method named `fetch_and` found for struct `AtomicUsize` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/rwlock.rs:363:19
    |
363 |         self.lock.fetch_and(!(WRITER | UPGRADED), Ordering::Release);
    |                   ^^^^^^^^^ method not found in `AtomicUsize`

error[E0599]: no method named `fetch_or` found for struct `AtomicUsize` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/rwlock.rs:415:22
    |
415 |         if self.lock.fetch_or(UPGRADED, Ordering::Acquire) & (WRITER | UPGRADED) == 0 {
    |                      ^^^^^^^^ method not found in `AtomicUsize`

error[E0599]: no method named `fetch_sub` found for reference `&'rwlock AtomicUsize` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/rwlock.rs:760:19
    |
760 |         self.lock.fetch_sub(READER, Ordering::Release);
    |                   ^^^^^^^^^ method not found in `&AtomicUsize`

error[E0599]: no method named `fetch_sub` found for struct `AtomicUsize` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/rwlock.rs:770:25
    |
770 |         self.inner.lock.fetch_sub(UPGRADED, Ordering::AcqRel);
    |                         ^^^^^^^^^ method not found in `AtomicUsize`

error[E0599]: no method named `fetch_and` found for struct `AtomicUsize` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/rwlock.rs:782:14
    |
780 | /         self.inner
781 | |             .lock
782 | |             .fetch_and(!(WRITER | UPGRADED), Ordering::Release);
    | |             -^^^^^^^^^ method not found in `AtomicUsize`
    | |_____________|
    |

error[E0599]: no method named `compare_exchange` found for reference `&AtomicUsize` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/rwlock.rs:796:16
    |
796 |         atomic.compare_exchange(current, new, success, failure)
    |                ^^^^^^^^^^^^^^^^ method not found in `&AtomicUsize`

error[E0599]: no method named `compare_exchange_weak` found for reference `&AtomicUsize` in the current scope
   --> /Users/vainogranat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spin-0.9.8/src/rwlock.rs:798:16
    |
798 |         atomic.compare_exchange_weak(current, new, success, failure)
    |                ^^^^^^^^^^^^^^^^^^^^^ method not found in `&AtomicUsize`

This branch https://github.com/vilukissa68/headsail-vp/tree/feat/asic-sysctrl-dla supplies sdram link.x for sysctrl.

hegza commented 2 days ago

I think the link script sdram_sysctrl.x is not present on https://github.com/vilukissa68/headsail-vp/tree/feat/asic-sysctrl-dla. Perhaps forgot to add it in tree.

The compile error is debuggable without it though. Link script is only queried for upon linkage (at end of build).

hegza commented 2 days ago

Issue is unrelated to headsail-sysctrl-pac. That just happened to be building simultaneously due to parallel build. Actual problem is with spin crate (which is producing the errors).

hegza commented 2 days ago

cargo tree -Falloc -i spin gives inverted deps:

spin v0.9.8
└── good_memory_allocator v0.1.7
    └── headsail-bsp v0.1.0
hegza commented 2 days ago

Root cause identified: the SpinLockAllocator of good_memory_allocator uses atomics. Atomics are not present for SysCtrl.

I'm not sure if an allocator can be implemented without atomics. You can look into it if you want to.