Skip to content

Instantly share code, notes, and snippets.

@hndrbrm
Created February 4, 2023 16:44
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hndrbrm/73713e2c33fb193685863ecde3440df7 to your computer and use it in GitHub Desktop.
Save hndrbrm/73713e2c33fb193685863ecde3440df7 to your computer and use it in GitHub Desktop.
Getting Started m0s dock bl616

Clone the sdk from bouffalo lab github.

git clone https://github.com/bouffalolab/bl_mcu_sdk

Use clion and open examples/helloworld as Makefile project (dont open it as cmake project).

Screen Shot 2023-02-04 at 23 04 35

After opening there will be error

Screen Shot 2023-02-04 at 23 06 21

The error happened because its use default phony rule 'all', which should be change into ''

Click the bench icon to modify it

Screen Shot 2023-02-04 at 23 06 54

Click the reload icon and it will shows successfull operation

Screen Shot 2023-02-04 at 23 07 15

Choose build mode.

Screen Shot 2023-02-04 at 23 13 31

And build it.

Screen Shot 2023-02-04 at 23 13 39

Note the build message on bottom

Screen Shot 2023-02-04 at 23 15 33

The second line will be used if we want to develop further on clion. For example to turn on code completion, etc.

After some time it will built successfull and theres will be file .bin

Screen Shot 2023-02-04 at 23 15 46

Screen Shot 2023-02-04 at 23 15 56

To download this firmware to the bl616, use BouffaloLabDevCube downloaded from bouffalo labs site:

https://dev.bouffalolab.com/download

Run the app, click the MCU tab, and choose the image file (use the .bin file)

Screen Shot 2023-02-04 at 23 23 07

Screen Shot 2023-02-04 at 23 23 13

Turn the UART mode on, by holding the boot button from off power then turn the power on, then release the button.

Click the refresh button, to refresh the list of uart devices.

Screen Shot 2023-02-04 at 23 26 25

Then the port will be populated

Screen Shot 2023-02-04 at 23 27 38

Then click create & download, and wait until the percentage bar turn into 100%

Screen Shot 2023-02-04 at 23 29 18

The next step is making a blinking led

copy the folder examples/helloworld to examples/blink

Delete the folder examples/blink/.idea and open the project as a cmake project

Replace 'CMake options' from the previous note, from '-G "Unix..." until last.

Then add environment for the path of mcu_sdk in BL_SDK_BASE

Screen Shot 2023-02-04 at 23 39 15

The cmake will be run and finish successfully

Screen Shot 2023-02-04 at 23 40 28

Then try to build it.

Screen Shot 2023-02-04 at 23 41 16

Screen Shot 2023-02-04 at 23 41 37

Next, replace the content of main.c with this:

#include "bflb_gpio.h"
#include "board.h"

struct bflb_device_s *gpio;

int main(void)
{
    board_init();

    gpio = bflb_device_get_by_name("gpio");
    printf("gpio output\r\n");
    bflb_gpio_init(gpio, GPIO_PIN_27, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);
    bflb_gpio_init(gpio, GPIO_PIN_28, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);

    while (1) {
        bflb_gpio_set(gpio, GPIO_PIN_27);
        bflb_gpio_reset(gpio, GPIO_PIN_28);
        bflb_mtimer_delay_ms(500);

        bflb_gpio_reset(gpio, GPIO_PIN_27);
        bflb_gpio_set(gpio, GPIO_PIN_28);
        bflb_mtimer_delay_ms(500);
    }
}

Then compile and download it to the bl616, the you see the led below the power led will be blinking.

@BurnerK
Copy link

BurnerK commented Jul 1, 2023

Hi, have you tried to build BL602/706 environment in CLION again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment