Re: [Nix-dev] Cross development for STM32

2016-08-28 Thread Tim Barbour
On Sat, 27 Aug 2016 03:28:49 +1000,
Alexey Shmalko wrote:
> 
> I usually produce raw binary file first:
> 
> $ arm-none-eabi-objcopy -O binary build/ch.elf ch.bin
> 
> and then flash that with openocd:
> 
> $ openocd -f openocd.cfg
> poll
> reset halt
> flash probe 0
> flash write_image erase ch.bin 0x0800
> reset
> 
> Note this unlikely to work for you, as your device is probably different.
> 
> Check out my Makefile (flash target) and openocd scripts:
> - https://github.com/rasendubi/bkernel/blob/master/Makefile#L70-L72
> - https://github.com/rasendubi/bkernel/blob/master/openocd.cfg
> - https://github.com/rasendubi/bkernel/blob/master/openocd.tcl

I think you have put my feet on the right path. Thank you.

I got so far as being able to connect openocd and halt the board, when
strangely openocd lost communication. Subsequently my stlink device stubbornly
fails to enumerate:

[Aug28 23:54] usb 9-1: new full-speed USB device number 2 using ohci-pci
[  +0.127987] usb 9-1: device descriptor read/64, error -62
[  +0.233991] usb 9-1: device descriptor read/64, error -62
[  +0.228991] usb 9-1: new full-speed USB device number 3 using ohci-pci
[  +0.127962] usb 9-1: device descriptor read/64, error -62
[  +0.234022] usb 9-1: device descriptor read/64, error -62
[  +0.228991] usb 9-1: new full-speed USB device number 4 using ohci-pci
[  +0.403983] usb 9-1: device not accepting address 4, error -62
[  +0.128992] usb 9-1: new full-speed USB device number 5 using ohci-pci
[  +0.403986] usb 9-1: device not accepting address 5, error -62
[  +0.006086] usb usb9-port1: unable to enumerate USB device

even though I have reset the USB subsystems, and even plugged it into a
different PC. Neither does its LED illuminate, whereas before it did.
I presume that it has failed, and am waiting for a replacement unit.

Tim
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cross development for STM32

2016-08-26 Thread Alexey Shmalko
I usually produce raw binary file first:

$ arm-none-eabi-objcopy -O binary build/ch.elf ch.bin

and then flash that with openocd:

$ openocd -f openocd.cfg
poll
reset halt
flash probe 0
flash write_image erase ch.bin 0x0800
reset

Note this unlikely to work for you, as your device is probably different.

Check out my Makefile (flash target) and openocd scripts:
- https://github.com/rasendubi/bkernel/blob/master/Makefile#L70-L72
- https://github.com/rasendubi/bkernel/blob/master/openocd.cfg
- https://github.com/rasendubi/bkernel/blob/master/openocd.tcl

On 08/26/2016 03:55 PM, Tim Barbour wrote:
> Thank you Philip and Alexey.
> 
> I have tried gcc-arm-embedded as you suggested, and had no trouble building
> the ChibiOS UART demo for a Maple Mini board (I did have to change GPIOC_LED
> to GPIOB_LED; presumably the demo was written for a board with more LEDs).
> 
> $ file build/ch.elf 
> build/ch.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), 
> statically linked, not stripped
> 
> $ arm-none-eabi-size build/ch.elf 
>textdata bss dec hex filename
>6880 416   20448   277446c60 build/ch.elf
> 
> I have yet to figure out how to get the code onto the board. Something like
> connecting to UART1 and starting the boot loader. I also have an stlink
> device, so openocd should work too, if necessary.
> 
> Tim
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
> 



signature.asc
Description: OpenPGP digital signature
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cross development for STM32

2016-08-26 Thread Alexey Shmalko
It's really simple and doesn't consume much resources by itself. I was able to 
shrink it down to 16Kb flash and 264 _bytes_ RAM.

That's a simple command line interface, GPIO, LED-blinking, USART, timers. Most 
flash memory is used by Rust printing utilities and may be shrinked down by 
disabling logging and exception handling.

On 08/26/2016 04:09 PM, Tim Barbour wrote:
> On Fri, 26 Aug 2016 22:23:46 +1000,
> Alexey Shmalko wrote:
>> [...]
>> Resources you may check out:
>> - my kernel for STM32F4Discovery which is 100% Rust 
>> (https://github.com/rasendubi/bkernel).
> 
> Interesting. How large is your kernel ? Would it fit in a small STM32 (128k
> flash, 20k RAM) ?
> 
> Tim
> 



signature.asc
Description: OpenPGP digital signature
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cross development for STM32

2016-08-26 Thread Tim Barbour
On Fri, 26 Aug 2016 22:23:46 +1000,
Alexey Shmalko wrote:
> [...]
> Resources you may check out:
> - my kernel for STM32F4Discovery which is 100% Rust 
> (https://github.com/rasendubi/bkernel).

Interesting. How large is your kernel ? Would it fit in a small STM32 (128k
flash, 20k RAM) ?

Tim
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cross development for STM32

2016-08-26 Thread Tim Barbour
Thank you Philip and Alexey.

I have tried gcc-arm-embedded as you suggested, and had no trouble building
the ChibiOS UART demo for a Maple Mini board (I did have to change GPIOC_LED
to GPIOB_LED; presumably the demo was written for a board with more LEDs).

$ file build/ch.elf 
build/ch.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), 
statically linked, not stripped

$ arm-none-eabi-size build/ch.elf 
   textdata bss dec hex filename
   6880 416   20448   277446c60 build/ch.elf

I have yet to figure out how to get the code onto the board. Something like
connecting to UART1 and starting the boot loader. I also have an stlink
device, so openocd should work too, if necessary.

Tim
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cross development for STM32

2016-08-26 Thread stewart mackenzie
I'd really like to see a simple nix way to retarget derivations.

So maybe `buildRustPackageForAndroid` or `buildRustPackageForSTM32`.

or maybe

buildRustPackage rec {
   name = "habitat-${version}";
   version = "0.8.0";
   target = "android";
   ...
}

kr/sjm
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cross development for STM32

2016-08-26 Thread Alexey Shmalko
To get Rust running on STM32 you need a cross-compiler first. Basically, rustc 
is backed by llvm, so you shouldn't rebuild it. However, you should build 
libcore for your target architecture.

After that, you can compile your application. I've being doing bare-metal 
programming, so I haven't compiled many other libraries.

Resources you may check out:
- my kernel for STM32F4Discovery which is 100% Rust 
(https://github.com/rasendubi/bkernel).
- cross-compilation guide 
(https://spin.atomicobject.com/2015/02/20/rust-language-c-embedded/)
- zinc.rs project (https://zinc.rs/). Though, I haven't used it.
- stm32.rs (https://github.com/japaric/stm32.rs).
- Philipp Oppermann's blog series on writing an OS with Rust 
(http://os.phil-opp.com/), though it's x86.

Hope this helps

On 08/26/2016 11:43 AM, Moritz Ulrich wrote:
> 
> Rust on STM32 mostly. I'm quite familar with Rust and Nix, but not with
> the STM32 yet.
> 
> Alexey Shmalko  writes:
> 
>> [ Unknown signature status ]
>> What part you're interested in? Nix, STM32, Rust?
>>
>> On 08/25/2016 03:41 PM, Moritz Ulrich wrote:
>>>
>>> Alexey Shmalko  writes:
>>>
 [ Unknown signature status ]
 Hi!

 I was also doing some STM32 development (but with Rust).
>>>
>>> I'm very interested in this. Can you share any resources (where to
>>> start, any guides, etc.)?
>>>
>>
> 



signature.asc
Description: OpenPGP digital signature
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cross development for STM32

2016-08-26 Thread Moritz Ulrich

Rust on STM32 mostly. I'm quite familar with Rust and Nix, but not with
the STM32 yet.

Alexey Shmalko  writes:

> [ Unknown signature status ]
> What part you're interested in? Nix, STM32, Rust?
>
> On 08/25/2016 03:41 PM, Moritz Ulrich wrote:
>> 
>> Alexey Shmalko  writes:
>> 
>>> [ Unknown signature status ]
>>> Hi!
>>>
>>> I was also doing some STM32 development (but with Rust).
>> 
>> I'm very interested in this. Can you share any resources (where to
>> start, any guides, etc.)?
>> 
>

-- 


signature.asc
Description: PGP signature
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cross development for STM32

2016-08-25 Thread Alexey Shmalko
What part you're interested in? Nix, STM32, Rust?

On 08/25/2016 03:41 PM, Moritz Ulrich wrote:
> 
> Alexey Shmalko  writes:
> 
>> [ Unknown signature status ]
>> Hi!
>>
>> I was also doing some STM32 development (but with Rust).
> 
> I'm very interested in this. Can you share any resources (where to
> start, any guides, etc.)?
> 



signature.asc
Description: OpenPGP digital signature
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cross development for STM32

2016-08-25 Thread Moritz Ulrich

Alexey Shmalko  writes:

> [ Unknown signature status ]
> Hi!
>
> I was also doing some STM32 development (but with Rust).

I'm very interested in this. Can you share any resources (where to
start, any guides, etc.)?
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cross development for STM32

2016-08-25 Thread Alexey Shmalko
Hi!

I was also doing some STM32 development (but with Rust).

My shell.nix[1] file is similar:

{ system ? builtins.currentSystem }:

let
  pkgs = import  { inherit system; };

  rust-nightly = pkgs.callPackage ./nix/rust-nightly {
date = "2016-05-28";
hash = "0f9rx672v97f5bn6mnb1dgyczyf5f8vcjp55yvasflvln1w64krv";
  };

in with pkgs; {
  bkernelEnv = stdenv.mkDerivation {
name = "bkernel";
buildInputs = [
  gnumake
  git
  rust-nightly
  gcc-arm-embedded
  minicom
  openocd
  expect
];
  };
}

[1]: https://github.com/rasendubi/bkernel/blob/master/shell.nix

On 08/25/2016 11:01 AM, Philip Potter wrote:
> Hi Tim,
> 
> I've been compiling some stuff for STM32 recently -- in particular,
> the micropython fork for the STM32-based TiLDA-Mk3 board [1][2]. I
> just had to install the gcc-arm-embedded package and I was able to
> start compiling code.
> 
> My shell.nix (for setting up a nix-shell development environment) was
> not particularly complicated:
> 
> let pkgs = import  {};
>   stdenv = pkgs.stdenv;
> in
> stdenv.mkDerivation {
>   name = "micropython-0.0.1";
>   buildInputs = with pkgs; [ git cmake python pythonPackages.pyusb
> pkgs.libusb1 gcc-arm-embedded ];
> }
> 
> With this, I was able to clone https://github.com/emfcamp/micropython
> and run `make -C stmhal BOARD=STM32L475_EMFBADGE` to build the .dfu
> file.
> 
> Phil
> 
> [1] https://badge.emfcamp.org/wiki/TiLDA_MK3
> [2] https://www.youtube.com/watch?v=sww4gJPse4o
> 
> On 25 August 2016 at 02:02, Tim Barbour  wrote:
>> I have some STM32 boards (e.g. Maple Mini) to play with. I am not trying to
>> port Nixos to them, because they are not really powerful enough to run Linux;
>> instead I plan to run ChibiOS/RT on them.
>>
>> I would appreciate suggestions as to a good way to setup an STM32
>> cross-development environment on Nixos, so that I can write software that 
>> will
>> run on (link with) ChibiOS/RT on the STM32 board.
>>
>> Tim
>> ___
>> nix-dev mailing list
>> nix-dev@lists.science.uu.nl
>> http://lists.science.uu.nl/mailman/listinfo/nix-dev
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
> 



signature.asc
Description: OpenPGP digital signature
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Cross development for STM32

2016-08-25 Thread Philip Potter
Hi Tim,

I've been compiling some stuff for STM32 recently -- in particular,
the micropython fork for the STM32-based TiLDA-Mk3 board [1][2]. I
just had to install the gcc-arm-embedded package and I was able to
start compiling code.

My shell.nix (for setting up a nix-shell development environment) was
not particularly complicated:

let pkgs = import  {};
  stdenv = pkgs.stdenv;
in
stdenv.mkDerivation {
  name = "micropython-0.0.1";
  buildInputs = with pkgs; [ git cmake python pythonPackages.pyusb
pkgs.libusb1 gcc-arm-embedded ];
}

With this, I was able to clone https://github.com/emfcamp/micropython
and run `make -C stmhal BOARD=STM32L475_EMFBADGE` to build the .dfu
file.

Phil

[1] https://badge.emfcamp.org/wiki/TiLDA_MK3
[2] https://www.youtube.com/watch?v=sww4gJPse4o

On 25 August 2016 at 02:02, Tim Barbour  wrote:
> I have some STM32 boards (e.g. Maple Mini) to play with. I am not trying to
> port Nixos to them, because they are not really powerful enough to run Linux;
> instead I plan to run ChibiOS/RT on them.
>
> I would appreciate suggestions as to a good way to setup an STM32
> cross-development environment on Nixos, so that I can write software that will
> run on (link with) ChibiOS/RT on the STM32 board.
>
> Tim
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] Cross development for STM32

2016-08-24 Thread Tim Barbour
I have some STM32 boards (e.g. Maple Mini) to play with. I am not trying to
port Nixos to them, because they are not really powerful enough to run Linux;
instead I plan to run ChibiOS/RT on them.

I would appreciate suggestions as to a good way to setup an STM32
cross-development environment on Nixos, so that I can write software that will
run on (link with) ChibiOS/RT on the STM32 board.

Tim
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev