tomipiriyev / Loko

Tiny GPS tracker with LoraWAN
MIT License
192 stars 30 forks source link

Communication issues with microcontroller - Loko Air #11

Open tyagodani opened 1 year ago

tyagodani commented 1 year ago

Hi,

Having assembled a couple of Air's, I was now messing with trying to see if I could get the microcontroller to respond to some AT commands, but I'm having little success. The serial port is identified without issues, but that is all I'm getting. No response to AT. I know this may be a little scarse information, but I'm not seeing from which end I should start troubleshooting more in depth. Would you be able to help?

Thanks in advance.

tomipiriyev commented 1 year ago

@tyagodani after firmware installation, connect to PC via USB , ( Note: USB C connector is not mirrored, it means USB C connector will work only in one position). Then use Putty to connect to serial , and on successful connection Loko will print data to terminal

tyagodani commented 1 year ago

Hi @tomipiriyev,

I had already noticed the USB connector not being mirrored, as it was only recognized in one orientation. That is sorted. I have tried with Putty and also Arduino IDE. I'm not getting a response from the microcontroller. I took some measurements to see if there was any issue with power being fed to it and discovered I needed to have the battery already connected, as with USB only, only about 1,74V were being delivered to the controller. Now it's right at 3V. I've also verified the serial drivers and everything looks OK. This is the only thing Putty displays when attempting to connect: image

tomipiriyev commented 1 year ago

@tyagodani if the firmware successfully uploaded ,( re-read the microcontroller to see if it is written ) . then look for IC1 , it is serial- USB converter, check its soldering .

tyagodani commented 1 year ago

@tomipiriyev okay so I shouldn't expect a response from the AT command. Can you provide some guidance on how to flash the firmware? Been looking around at the files but don't seem to get it 🙃 Thanks boss

tyagodani commented 1 year ago

@tomipiriyev I figured out that you write the firmaware with STM32CubeProgrammer. However, I'm still facing the same issue where I can see the serial converter from my computer, but it can't communicate with the microcontroller. I've checked the soldering and it looks fine (it came soldered from JLCPCB). All 3 units I have assembled are showing the exact same behaviour. Any furrther ideas of what might be the issue?

tyagodani commented 1 year ago

These are the configs I'm using: image

tomipiriyev commented 1 year ago

@tyagodani yes , please use Cube programmer, Why 9600 ? change it to 11500. STM32 comes in protected, need to first delete inside, and then you will be able to read stm32 memory, and then upload the firmware. Also can you try to use P1 connector to connect to st-link .

Also sorry for my late reply , I am a little sick in these days .

tyagodani commented 1 year ago

@tomipiriyev no problem and thank you for your availability and patience. have a speedy recovery.

I've chnaged the baud rate to 115200 (guessing the 11500 you typed was a mistake), but I'm getting the same. This is the list of available baud rates: image

Connection logs: 12:44:01 : UR connection mode is defined with the HWrst reset mode 12:44:01 : RTS low 12:44:01 : DTR low 12:44:01 : Serial Port COM4 is successfully opened. 12:44:01 : Port configuration: parity = none, baudrate = 115200, data-bit = 8, stop-bit = 1.0, flow-control = off 12:44:03 : Timeout error occured while waiting for acknowledgement. 12:44:03 : Error: Activating device: KO. Please, verify the boot mode configuration and check the serial port configuration. Reset your device then try again...

tyagodani commented 1 year ago

I am now sure that this is a hardware issue. I've tried this on 2 different Air's, one with and one without the battery, and the issue is the exact same.

Scenario 1: USB disconnected VBAT = 2.84V LoRa_Supply = 0.0V Voc (bat_protection) to GND = -2.24V Voc (bat_protection) to GND_BAT = 0.0V

Scenario 2: USB connected VBAT = 2.84V LoRa_Supply = 1.73V Voc (U5) to GND = -2.24V Voc (U5) to GND_BAT = 0.0V Vod (U5) to GND = 1.73V Vod (U5) to GND_BAT = 2.81V

I've double and tripple checked the component orientation, soldering and continuity between the USB connector, U5, Q7, U8 and U1.

Do you have any idea on what else I should check to try to find the underlying issue? Thank you a lot for your time.

tomipiriyev commented 1 year ago

@tyagodani battery below 3v battery protection will disconnect the battery, it is empty. voltage is low on Lora_Supply , can you show picture of your connection to ST-link please

tyagodani commented 1 year ago

@tomipiriyev I will attempt to charge the battery externally. But shouldn't the microcontroller be receiving the correct voltage when USB is connected? I don't have an ST-Link programmer. Isn't it possible to program over USB?

tomipiriyev commented 1 year ago

@tyagodani STM32 microcontroller pins are not set as default to use for USB , so in first time, it needs to be programmed with st-link programmer.

When the button is pressed MCU Should be powered with 3v ,

tyagodani commented 1 year ago

@tomipiriyev "When the button is pressed MCU Should be powered with 3v" This even without programming the MCU, correct?

tomipiriyev commented 1 year ago

@tyagodani "When the button is pressed MCU Should be powered with 3v" this is not correct, my mistake .

you should have 3v when it is powered from usb +battery . but battery should be over 3v , please first charge the battery and then test .

tyagodani commented 1 year ago

@tomipiriyev tested now with a charged battery and the results seem to be better! The MCU is now receiving the propper voltage and the battery is charging via the Loko.

Over serial, I am getting the following (baud rate at 115200):

UART-BL v1.0.0
CCCCCCCCCCCCCCC

I'm now waiting on the ST-Link. To which pins should I connect after to program it?

tyagodani commented 1 year ago

@tomipiriyev got the ST-Link and managed to connect to the MCU. however, I'm getting data read failed error. Already verified all pins are connected corrrectly to P1, including the NRST. I'm unable to erase the chip, but can see its details: image Error:

  01:16:45 : STM32CubeProgrammer API v2.13.0 | Windows-64Bits 
  01:16:54 : UR connection mode is defined with the HWrst reset mode
  01:16:54 : ST-LINK SN  : 210031000800004E4B52524E
  01:16:54 : ST-LINK FW  : V2J43S7
  01:16:54 : Board       : --
  01:16:54 : Voltage     : 3.29V
  01:16:54 : SWD freq    : 4000 KHz
  01:16:54 : Connect mode: Normal
  01:16:54 : Reset mode  : Hardware reset
  01:16:54 : Device ID   : 0x497
  01:16:54 : Revision ID : Rev Y
  01:16:55 : UPLOADING OPTION BYTES DATA ...
  01:16:55 :   Bank          : 0x00
  01:16:55 :   Address       : 0x58004020
  01:16:55 :   Size          : 96 Bytes
  01:16:55 :   Bank          : 0x01
  01:16:55 :   Address       : 0x58004080
  01:16:55 :   Size          : 8 Bytes
  01:16:55 : UPLOADING ...
  01:16:55 :   Size          : 1024 Bytes
  01:16:55 :   Address       : 0x8000000
  01:16:55 : Read progress:
  01:16:55 : Error: Data read failed

Any tips on what to check?

tomipiriyev commented 1 year ago

@tyagodani can you please share more photo from stmprogrammer screen shout, and hardware connection

tyagodani commented 1 year ago

@tomipiriyev it may be a little hard to see on the photos, but: yellow: 3.3V green: GND white: RST orange: SWDIO blue: SWCLK

image image image image image image

ST-Link configuration: image

tomipiriyev commented 1 year ago

@tyagodani if you supply the voltage from the st-link programmer , remove the battery . then try . it should work. I do the same setup as you, only I use different type st-link programmer. never tried with the one that you use. if it will not help , we can set a call , and we can debug the issue together.

tyagodani commented 1 year ago

@tomipiriyev I have tried both with and without the battery installed. May I ask what version of the ST programmer software you are using? Cheers

tomipiriyev commented 1 year ago

@tyagodani day after tomorrow I will set up the exact same configuration with yours , so we can go over it . I use STM32CubeProgrammer v2.10.0 on Mac ( the st-link programmer you use might be the issue, not sure, in internet I can see that some other people having similar issue )

tyagodani commented 1 year ago

@tomipiriyev so, at long last, I've managed to resolve the data reading error. It wasn't the programmer, but rather one of the Read Out Protection parameters on the software.

For anyone reading this in the future and facing a similar issue, this is what I did to resolve the issue (props to this post on the Seeed Studio forums: https://forum.seeedstudio.com/t/how-to-program-a-lora-e5/257491):

Initially connect using the following configuration: image

The "data read failed" pop-up will show. Dismiss it. The software should remain connected to the MCU. Check on the bottom right corner for the "Target information" fields to be populated like this: image

On the hamburger menu on the left, select "Option bytes": image

Under "Read Out Protection", change the "RDP" parameter value from "BB" to "AA" and hit "Apply": image

After a few seconds, a bunch of errors like these will appear, but fear not: image

Now just simply unplug the programmer from the computer, plug it back in and you can connect in Normal Mode successfully.

tomipiriyev commented 1 year ago

@tyagodani thank you for your very clear explanation of the problem , it will be very helpful for other people as well. Also sorry that I forgot to simulate the same setup on my side, I am a little busy , I completely forgot.

Also here I have added Loko configuration tool with GUI , with easy configuration.

tomipiriyev commented 1 year ago

@tyagodani you have mentioned that you ordered assembled units from JLC, if it is not secret. how much it cost to order full assembled board from JLC?

tyagodani commented 1 year ago

@tyagodani you have mentioned that you ordered assembled units from JLC, if it is not secret. how much it cost to order full assembled board from JLC?

@tomipiriyev I did not get all components assembled by JLC, as they did not have them all available. The GPS sensor, diodes Q1 and Q2, the MCU and USB connector I had to source from different places and soldered them myself. Nonetheless, the total for 5 boards was ~115€ + Shipping + Tax + the other components I mentioned were missing. Higher quantity orders will equate to a much better per unit price. For example, 20 boards only cost ~198€ at this time (9,90€ vs 23,00€ per board).

tyagodani commented 1 year ago

@tomipiriyev regarding the configuration tool, I'm assuming you only uploaded the MacOS version, correct?