# Flashing a bin to Hifive1 without SDK

**URL:** <https://forums.sifive.com/t/flashing-a-bin-to-hifive1-without-sdk/5116>\
**Category:** HiFive1 Rev B\
**Created:** [August 25, 2021, 6:02am UTC](https://forums.sifive.com/t/flashing-a-bin-to-hifive1-without-sdk/5116 "2021-08-25T06:02:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![neo\_ar](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/neo_ar/32/792_2.png) [@neo\_ar](https://forums.sifive.com/u/neo_ar)\
**Post date:** [August 25, 2021, 6:02am UTC](https://forums.sifive.com/t/flashing-a-bin-to-hifive1-without-sdk/5116/1 "2021-08-25T06:02:20Z")

</div>

(This is with regard to the original HiFive1, not Rev B)

Just want to double check with you guys before I accidentally brick it… 😉

I’m thinking about demoing running a program from my [~100 line assembler](https://twitter.com/hmn_riscy/status/1427600055985491982) on real hardware.

I understand the OTP boot sequence and how it jumps to flash at 0x20000000. The original Freedom-E-SDK (branch v1\_0) has the double\_tap\_dontboot bootloader code placed there which ultimately jumps to user code at 0x20400000. That much we learned on [RISCY BUSINESS (shameless plug ;O)](http://cinera.riscy.tv/).

Given that I want to use the [double\_tap\_dontboot code](https://github.com/sifive/freedom-e-sdk/blob/v1_0/software/double_tap_dontboot/double_tap_dontboot.c) already on the board, is it safe for me to simply do:

`openocd -f hifive1.cfg -c "program demo.bin exit 0x20400000"`

where hifive1.cfg is the appropriate openocd cfg for the hifive1 board (pulled from the Freedom-E-SDK) and demo.bin holds the raw machine code & data for my demo?

Also how do the [original Freedom-E-SDK v1\_0 hifive1 openocd cfg](https://github.com/sifive/freedom-e-sdk/blob/v1_0/bsp/env/freedom-e300-hifive1/openocd.cfg) and the [current Freedom-E-SDK hifive1 openocd cfg](https://github.com/sifive/freedom-e-sdk/blob/master/bsp/sifive-hifive1/openocd.cfg) compare (should I use the newer one?)

---

<div class="post-metadata">

**Author:** ![vmedea](https://avatars.discourse-cdn.com/v4/letter/v/3be4f8/32.png) [@vmedea](https://forums.sifive.com/u/vmedea)\
**Post date:** [August 25, 2021, 12:18pm UTC](https://forums.sifive.com/t/flashing-a-bin-to-hifive1-without-sdk/5116/2 "2021-08-25T12:18:45Z")

</div>

> Also how do the [original Freedom-E-SDK v1\_0 hifive1 openocd cfg](https://github.com/sifive/freedom-e-sdk/blob/v1_0/bsp/env/freedom-e300-hifive1/openocd.cfg) and the [current Freedom-E-SDK hifive1 openocd cfg](https://github.com/sifive/freedom-e-sdk/blob/master/bsp/sifive-hifive1/openocd.cfg) compare (should I use the newer one?)

It looks like the main difference, concerning flash, is whether flash is unprotected at the end. On master there is this line:

```auto
flash protect 0 64 last off

```

For v1\_0 this line is commented out. It doesn’t matter because the same unprotect command is issued through gdb’s `monitor` in either case, on master’s [scripts/upload](https://github.com/sifive/freedom-e-sdk/blob/master/scripts/upload):

```bash
export GDB_PORT=3333
$openocd -f $cfg &
$gdb $elf --batch -ex "set remotetimeout 240" -ex "target extended-remote localhost:${GDB_PORT}" -ex "monitor reset halt" -ex "monitor flash protect 0 64 last off" -ex "thread apply all set \$pc=_enter" -ex "load" -ex "monitor resume" -ex "monitor shutdown" -ex "quit"
kill %1

```

In v1\_0 this happens through a [Makefile](https://github.com/sifive/freedom-e-sdk/blob/v1_0/Makefile):

```auto
…
GDB_UPLOAD_CMDS += -ex "monitor flash protect 0 64 last off"
…

```

I’ve never tried flashing without gdb. But as you say, if you make sure you flash from `0x20400000` (never `0x20000000`) I would assume it is safe because the binaries produced by the SDK start there as well.
