imxrt-rs/imxrt-hal

Upload to EVK

alexandruradovici opened this issue · 7 comments

Hi guys,

Great work! A quick question. Did you succeed in loading this to an EVK device? I am trying to upload the following program using mcuxpresso's GUI Flash tool to an imxrt1052 EVKB, it seems to upload it, but fails to light up the LED.

I would appreciate any feedback :)

//! Prints "Hello, world!" on the host console using semihosting

#![no_main]
#![no_std]

extern crate panic_halt;

use cortex_m_rt::entry;
use cortex_m_semihosting::{debug, hprintln};
use imxrt_ral::{read_reg, write_reg, modify_reg, reset_reg};
use imxrt_ral::{gpio};

fn set_pin_9(gpio: &gpio::RegisterBlock) {
    write_reg!(gpio, gpio, GDIR, 1<<9);
    write_reg!(gpio, gpio, DR, 1<<9);
}

#[entry]
fn main() -> ! {
    // exit QEMU
    // NOTE do not run this on hardware; it can corrupt OpenOCD state
    // debug::exit(debug::EXIT_SUCCESS);

    let gpio1 = gpio::GPIO1::take().unwrap();
    set_pin_9 (&gpio1);
    loop {}
}

memory.x

MEMORY
{
  /* Define each memory region */
  FLASH (rx) : ORIGIN = 0x60000000, LENGTH = 0x4000000 /* 64M bytes (alias Flash) */  
  RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x20000 /* 128K bytes (alias RAM) */  
}

You most likely need to setup the boot-gen (https://github.com/imxrt-rs/imxrt-boot-gen) stuff and use the imxrt1062-rt crate which places a few things at various memory addresses. I've been working on the hal GPIO stuff before attempting to get it going on my 1062 evk and 1011 evk. I'm hoping to try that stuff out this week and get a sample app going. If you beat me to it, please do share so we can put it up here!

So some updates on this, I did try to build and run a sample on the board in a few different ways, and when it didn't run right away I started digging. It looks like perhaps some linker script issues that I need to sort out. I've made some issues in this repo and the imxrt-rt repo if you'd like to follow along or add to the discussions. If its not the linker script then its the interrupt vector table being setup incorrectly, possibly due to the issues with linker scripts at the moment.

I finally got it running, I posted the example here https://github.com/alexandruradovici/imxrt1052evkb-quickstart. Not very sure yet why it is working, still need to figure out some things.

So looking closer at the NXP SDK they enable some clock gates to allow gpio outputs. I haven't done that yet but I did manage to get a basic program running now which I'm quite happy about.

See the imxrt1060evk-bsp examples to see where I got if you like

So final conclusion here is that you'd likely need to enable some clocks and set the iomux's pin config to be ALT5 for gpio usage.

The hal will take care of all of this as we move forward. Let me know if that helps or if there's more we can do to help in the meantime.

Just an update, the 1060evk now has blinking leds, uarts, timers, and pwm working. I'm going to close this issue unless you intend on working on a 1050evk BSP and feature flag for the hal, which we would gladly accept!

Feel free to reopen or open new issues if you like. Closing for now