BM71 No UART Response

Posted by in Electrical Engineering

First of all Microchip BM71 is the shittiest module I have ever seen in my life. The antenna gain is poor. Documentation is so bad that simple things are missing and maximum throughput is limited to 3KB/s with 10ms as minimum connection interval. You can find how I calculate the throughput by checking on this article about BLE specification. Here I assume you had the module. Already tried to communicate with it through UART and you failed to get any response back and now you are wondering why the module won’t reply.

The answer is quite simple, because the module is in the Transparent Mode. Transparent Mode is a state which all UART data sent to the module will simply sent out on bluetooth and no matter what you send in, the module wont respond you back. This state is sufficient if you want to send/receive data for simple tasks. But as soon as you need to change Device Name, TX Power or anything else you are stuck.

To get around this, In the Microchip way you have no way but to buy BM71 PICtail evaluation board. Although this should be simple and straightforward I don’t like how it sound. I mean  ّI hate this marketing method that “Buy our evaluation board or you can’t use the module”. So here is a workaround to overcome this problem without access to PICtail.

Program BM71 Without PICtail EVM

My module is BM71BLES1FC2-0002AA which according to datasheet must use the PC tools ending with 0002AA. BM71 Module use IS1871 chip inside. It is a little confusing but inside IS1871 page there exist a Firmware & Software Tools v1.06 (matched to my model) that have all necessary tools to configure and update BM71 module firmware.

Now here if your customized board have a high performance uController on it you just need to create a shadow CDC device that get all data coming from USB and send it to BM71. So the all fancy PICtail EVM is nothing more than a “usb to serial (UART)” converter. you need a high performance uColntroller as if the conversion speed is not fast enough isupdate Firmware updateTool through error into your face as it did happen to me. In the case you face the same error as me you need to get knowing IS1870 chip better so you can write your own firmware update tool.

IS1871 Memory Map

IS1871 have 256 Kbytes embedded Flash memory that have all firmware and module configuration. The firmware is the software that operate module during normal operation and configuration is a part of firmware that indicate Device Name, TX Power and anything else that specified as a option in the datasheet.

The firmware start from address 0x0000 and end in 0x40000. The configuration start from 0x35000 and end in 0x37000 with 0x2000 as length. The module use a firmware called BLEDK3. To change the setting for module you have to first generate the configuration header and then write the generated file to the mentioned memory address. For header generation there exist a tool with name IS187x_102_BLEDK3_UI v100.123 inside UserInterfaceTool_V100_123 folder of Firmware & Software Tools v1.06 that you downloaded earlier.

If you need more detail on how to do this please feel free to leave a comment below.

Preparing For Writing To BM71

There are 3 steps you need to do before you able to write any data on BM71.

Step 1: Enter EEPROM Mode

There is a special mode that called eeprom mode (or programming mode). The first step is to enter eeprom mode that clearly explained in the manual and BM71 datasheet. in a few words, you need to set a special pin and while holding the pin at specified level, reset the module

Step 2: Connect To Module

After entering eeprom mode, the module stop the LED blinking (if you had one on your board). then you need to send 0x01, 0x05, 0x04, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 I don’t know why this and what data they represent but sending out this will get the state machine to “CONNECTED” state. If the operation is successful you should get something from module (If you need to know the exact response feel free to ask)

Step 3: Erase The Flash

This step seems optional but it’s not. If you don’t send erase command before writing, any attempt to change memory will result in fail writing and memory won’t change. Again I don’t know why is module working this way or if I using it in a wrong way but I can’t write any register if I don’t send Erase command before to do so.

Secondly I don’t know where the erase command does actually erase. On my simple check this command only erase configuration area that I specified before and firmware remained unchanged but I’m not sure if it’s always the case.

To erase flash send 0x02, 0xFF, 0x0F, 0x0E, 0x00, 0x12, 0x01, 0x0A, 0x00, 0x03, 0x00, 0x00, 0x40, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00 any response should indicate the erase operation is successful. I highly recommend to wait 1 second before sending any further command.

I noticed that the flash operation have some inside timeout watch dog. If the writing command execute later than this timeout any write attempt result in failure.

Step ∞: Disconnect

The last step after all read/write operation is disconnection. This option seems to be optional but highly recommended to execute. The disconnect packet is 0x01, 0x06, 0x04, 0x03, 0xFF, 0x0F, 0x00

BM71 Writing

To write a register we start with a base command template then fill it with appropriate value.

Write Template: 0x02, 0xFF, 0x0F, 0x0E, 0x00, 0x11, 0x01, 0x0A, 0x00, 0x03, 0x00, 0x00, 0x46, 0x03,0x00, 0x20, 0x00, 0x00, 0x00

packet_size = data_size + 19;
address = 0x35000;

write_temp[3] = 14 + data_size;//ACL
write_temp[5] = 0x11; //COMMAND=WRITE
write_temp[7] = 10 + data_size;//ISDAP
write_temp[15] = block_size;//LENGTH
memcpy(&write_temp[11],(uint8_t*) &address, sizeof(address));//ADDRESS
memcpy(&write_temp[19],(uint8_t*) (eeprom_table), data_size);//Data

The data_size is in byte. In above example I used data_size=16. On a successful write, BM71 return 0x02, 0xFF, 0x0F, 0x0E, 0x00, 0x10, 0x01, 0x0A, 0x00, 0x03, 0x00, 0x00, 0x46, 0x03,0x00, 0x20, 0x00, 0x00, 0x00 on a failure due to requirement for flash, the second to last 0x00 will changes to 0x01.

Enable Wake Up by Keyboard/Mouse on Arch Linux

Posted by in Linux

The power button on my pc case is not very handy to work with, which made waking up by mouse/keyboard an awesome idea. The first thing to achieve this is obviously, getting inside bios and enable the wake up option for keyboard/mouse, LAN or whatever you like. You probably at this step expect that things get to work out of the box.

Well…. probably no. but still you got chance. from my experience some device works out of the box and some simply don’t. why? I think because they are a little too complicated for ACPI to handle them. Here I summarize my workaround to get these kind of devices work.

Step 1: Find device path

First of all you need to find device path. Device path is both the way that the device is connected to your computer and also the way you can access your device settings on your computer. To get this path, all you need is to find your keyboard/mouse node on /dev path and feed it to udevadm. As an example for my keyboard executing something like

udevadm info -q path -n /dev/input/event0

give this path and for mouse executing

udevadm info -q path -n /dev/input/mouse0

Step 2: Find your lucky wakeup file

Next you need to surf on your device path and find a file named wakeup. it may be in your device path/power. if not look it parent directory and foreword until you find the right file. For example in my case, wakeup file turned out to be /sys/devices/pci0000:00/0000:00:14.0/usb1/1-13/power/wakeup. Then you should write enabled inside this file by running

sudo sh -c "echo enabled > '/sys/devices/pci0000:00/0000:00:14.0/usb1/1-13/power/wakeup'"

If you are standing on a right place then probably double clicking cause your pc to wake up after suspension. if not try to looking the parent folder.

Step 3: Make The Process into Auto mode

As you know udev let you run script if specific device connected to the kernel, we exploit the idea and enable wakeup for our little cute mice.

SUBSYSTEM=="usb", ATTRS{idVendor}=="1b1c", ATTRS{idProduct}=="1b19" RUN+="/bin/sh -c 'echo enabled > /sys$env{DEVPATH}/../power/wakeup;'"

Hope You Enjoy

Install ADS 2015.01 on Arch Linux

Posted by in Electrical Engineering

Advanced Design System officially support RHel 5, RHel 6 and Solaris 10. My desktop use ARCH Linux, which is not listed in the support platforms. So some steps have to taken before get ADS to work. Here I summarize my walkaround on installing ADS on Arch Linux platform which it may or may not be possible to applied on any distribution other than Arch.

Installation Steps:

  1. Install ADS on your PC using shell script. Keep in mind that Install ADS on a path with no white-space or special character, although ADS setup does not complain, this cause fatal error in ADS runtime.
  2. From try and error it seems that ADS use Qt 4.8.6 which is have minor changes that make it incompatible with Qt4 provided from arch repository. Fortunately Qt 4.8.6 is packed inside ADS path, so it can be readily used by adding it to LD_LIBRARY_PATH environment variable.
    Edit LD_LIBRARY_PATH in <ADS_PATH>/bin/ads

  3. Create a duplicate from and rename it to in <ADS_PATH>/SystemVue/2014.10/linux_x86_64/bin/MATLABScript/sys/os/glnxa64. This may seems weird, so just to be clear out libXm is for Solaris platform (desktop environment). We create this file just to prevent from linking error which is not cause any further problem as while as the running platform is not Solaris.
  4. Install  Dependencies which is needed by License ManagerADS software.
    sudo pacman -S lsb-release libxp
    yaourt ld-lsb
    yaourt ksh
  5.  Run <ADS_PATH>/bin/ads

License Setup:

HostName: the computer name can be achieved by running following command

$uname -a 
 Linux Bijan-PC 4.4.7-1-lts #1 SMP Thu Apr 14 17:26:39 2016 x86_64 GNU/Linux

which is revealed that my HostName is Bijan-PC
There is no MAC Address need for Linux platform on the other hand ADS use so-called CPUID which generate based on your platform which can be used to get license file from KeySight Corporation. CPUID, MAC and HostID are all the same. note that HostID is different from HostName

How to Program Cortex M under GNU/Linux Arch

Posted by in Hobby Electronic, Linux

You may serach out all sites but there isn’t any adequate context in this subject. ARM family is a new platform that it’s compiler and other toolchains also matured recently so unfortunately there isn’t much quick start guide available out there. Here, I try to fill this gap and give you a hint about how to begin developing your fresh ARM-based board under GNU/Linux. Throughout this tutorial I work out with STM32F4 Discovery development board and Arch Linux distribution. If your board or your distribution is different don’t worry, with a little efforts all steps can be applied into your case.

Required tools:

sudo pacman -S arm-non-eabi-gcc

After installing toolchains you need to download CMSIS library for your microcontroller. CMSIS is a vendor based library, written to interface CPU and peripherals control register in a delicate manner. In our case, ST Microelectronic CMSIS library known as STMCube F4, can be downloaded from STMicroelectronics webpage.

Each stm32 device carry out with a two user manual so-called Programming Manual and Reference Manual. Reference Manual address to each peripheral registers and unit description. On the other hand Programming Manual show how to employ interrupt and hook up booting process. Both these manuals are essential in programming ARM microcontroller so ensure to have them before you start.

Unfortunately for the time being I’m busy to write down full guide on programming Arm Coretex M. so if you are in hurry to get things to work you can checkout our git repository for a clean and simple blink LED project. please keep in mind that follow all above steps and check ReadMe folder in the repository befor jump into the final stage.

Hello World!

Posted by in Casual

Hello, My name is Bijan Binaee. I’m an Electrical Hobbyist/Engineering enthusiast, currently studying electrical engineering at ECE School of University of Tehran .
You have found my little corner on the Internet.  This division includes lots of work on making things to work from simple blink LED to interfacing CSI camera capturing fowl movements.
I enjoy analyzing systems with complex interactions, and this has led me to delve the depths of Linux Kernel, GTK and other softwares.
Today is Easter Saturday. Not a day marked on most calendars.
But it is a very important day nonetheless, the day that I sit in my office, think about a question in my mind and spend hours to fulfill it no matter what. So if I have a little luck with me I found answer and wrote it all down to here.

Hope you enjoy,

Recent Comments