Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run the quickstart code on LPCXpresso55S69? #122

Open
tarun0yadav opened this issue Jun 4, 2023 · 0 comments
Open

How to run the quickstart code on LPCXpresso55S69? #122

tarun0yadav opened this issue Jun 4, 2023 · 0 comments

Comments

@tarun0yadav
Copy link

I am trying to run the sample code on my LPCXpresso55S69 board. My goal is just to print "in main" on my terminal through main function. I am using following jlink.gdb

# source .gdb-dashboard
set history save on
set confirm off
set pagination off
define rebootloop
  while (1)
    run
  end
end

target extended-remote :2331
load
monitor reset
monitor semihosting enable
monitor semihosting IOClient 3
continue

My main.rs code is:

#![no_std]
#![no_main]

#[macro_use]
extern crate delog;
generate_macros!();

// pick a panicking behavior
use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch panics
// use panic_abort as _; // requires nightly
// use panic_itm as _; // logs messages over ITM; requires ITM support
// use panic_semihosting as _; // logs messages to the host stderr; requires a debugger

use cortex_m::asm;
use cortex_m_rt::entry;

#[entry]
fn main() -> ! {
    // asm::nop(); // To not have main optimize to abort in release mode, remove when you add code
    info_now!("In main");

    loop {
        // your code goes here
    }
}

When I run code, it does not print anything and goes in the forever loop. I tried to add a breakpoint at "info_now!("In main");" but even after breakpoint, it always goes to loop. I am assuming my memory.x might be messed up.
memory.x

MEMORY
{
  /* NOTE 1 K = 1 KiBi = 1024 bytes */
  /* TODO Adjust these memory regions to match your device memory layout */
  /* These values correspond to the LM3S6965, one of the few devices QEMU can emulate */
    FLASH : ORIGIN = 0x00000000, LENGTH = 512K

    FILESYSTEM: ORIGIN = 0x00080000, LENGTH = 118K

    /* for use with standard link.x */
    RAM : ORIGIN = 0x20000000, LENGTH = 256K
}

terminal output:

cargo run --release --features log-all,log-info,log-semihosting
warning: unused import: `cortex_m::asm`
  --> src/main.rs:14:5
   |
14 | use cortex_m::asm;
   |     ^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: `test-rust-cortex-app` (bin "test-rust-cortex-app") generated 1 warning (run `cargo fix --bin "test-rust-cortex-app"` to apply 1 suggestion)
    Finished release [optimized + debuginfo] target(s) in 0.08s
     Running `arm-none-eabi-gdb -q -x jlink.gdb target/thumbv8m.main-none-eabi/release/test-rust-cortex-app`
Reading symbols from target/thumbv8m.main-none-eabi/release/test-rust-cortex-app...
test_rust_cortex_app::__cortex_m_rt_main () at /Users/tarun.yadav/Desktop/test-rust-cortex-app/src/main.rs:22
22	    loop {
Loading section .vector_table, size 0x400 lma 0x0
Loading section .text, size 0x27c lma 0x400
Start address 0x00000400, load size 1660
Transfer rate: 13280 bits in <1 sec, 830 bytes/write.
Resetting target
Semi-hosting enabled (Handle on breakpoint instruction hit)
Semihosting I/O set to TELNET and GDB Client
^C
Program received signal SIGTRAP, Trace/breakpoint trap.
cortex_m_rt::Reset () at src/lib.rs:526
526	        () => main(),
(gdb) break main.rs:18
Breakpoint 1 at 0x3c (2 locations)
(gdb) run
Starting program: /Users/tarun.yadav/Desktop/test-rust-cortex-app/target/thumbv8m.main-none-eabi/release/test-rust-cortex-app 
[New Thread 57005]
[Switching to Thread 57005]

Thread 2 hit Breakpoint 1, test_rust_cortex_app::__cortex_m_rt_main () at /Users/tarun.yadav/Desktop/test-rust-cortex-app/src/main.rs:22
22	    loop {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant