Monday, 6 September 2021

openOCD Debug STM32

If working remotely, everything is terminal. No GUI like stm32cubeide to use for firmware debugging. I need to use openOCD now. I am using a stm32f407 discovery board for the following tests.

1. install openOCD
sudo apt-get install openocd
cd /usr/local/share 
sudo ln -s /usr/share/openocd .

2. install toolchain
sudo apt install gcc-arm-none-eabi

3. install stm32cubeMX
Generate a project with makefile.

4. go the project directory and make the project.

5. make a cfg file

cd /usr/local/share/openocd/scripts/board

boris@boris-T420:/usr/local/share/openocd/scripts/board$ sudo cp stm32f4discovery.cfg stm32f407discovery_boris.cfg

6. Terminal 1: launch openOCD to connect to the board

openocd -f /usr/local/share/openocd/scripts/board/stm32f407discovery_boris.cfg

You can see the following problem:


7. edit the cfg file


Now it works:


8. Terminal 2: start GDB

go to the project directory, go to build/

PATH/TO/PROJECT/build$ arm-none-eabi-gdb openocd_practice.elf



9. now in gdb teminal, start debuging:
ref:
https://www.youtube.com/watch?v=yDNbpXjWAuU&ab_channel=AimalKhan



ref:

https://www.youtube.com/watch?v=yDNbpXjWAuU&ab_channel=AimalKhan
https://www.youtube.com/watch?v=Df7gtGyQaxg&t=512s&ab_channel=EmbeddedTips
http://forum.chibios.org/viewtopic.php?t=3425
https://elinux.org/OpenOCD_Ubuntu_Package

Friday, 3 September 2021

First Time Setting New MT7688 Module

 Got a new module, how to set network easily?

1. Connect your PC to the WAN port.

2. Serial connect to the board:

$ screen /dev/ttyUSB0 57600

$ ifconfig

br-lan Link encap:Ethernet HWaddr 1C:88:79:56:43:0F
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fd40:27d8:7c5f::1/60 Scope:Global
inet6 addr: fe80::1e88:79ff:fe56:430f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1333 errors:0 dropped:0 overruns:0 frame:0
TX packets:1284 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:92554 (90.3 KiB) TX bytes:106278 (103.7 KiB)

3. Go back to PC and open a browser, put down 192.168.1.1

Default password is root.



Saturday, 9 January 2021

ROS Tinkering - 01: 'package_name' is not a package

PROBLEM:

My source code structure is: ./my_project/app_ws/src/abc/abc.py and abc.py is node abc's entry python module.

My CMakelists.txt says:
    project(abc)

My package.xml says:
   <name>abc</name>

$ rosrun abc abc.py 

Traceback (most recent call last):
   File "/home/xxx/workspace/my_project/install/abc/lib/abc/abc.py", line 35, in <module>
    from abc.srv import LoadExperiment, LoadExperimentResponse

File "/home/xxx/workspace/my_project/install/abc/lib/abc/abc.py", line 35, in <module>
    from abc.srv import LoadExperiment, LoadExperimentResponse
ModuleNotFoundError: No module named 'abc.srv'; 'abc' is not a package


Solution:

ROS cannot handle the same name abc as the package name and same as the entry python module file. So just change the entry python module's name to abc_node.py or something else.



Saturday, 3 October 2020

Docker Tinkering: Troubleshoot Is the docker daemon running? Problem

 Got this error:

$ sudo docker build -t name:version .

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

ERRO[0000] failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial unix /var/run/docker.sock: connect: connection refused 

Also problem can be seen down below:

$ sudo service docker status

● docker.service

   Loaded: masked (/dev/null; bad)

   Active: inactive (dead) since Fri 2020-10-02 13:34:41 EDT; 1 day 7h ago

 Main PID: 32072 (code=exited, status=0/SUCCESS)


Solution:

$ sudo systemctl unmask docker

Removed /etc/systemd/system/docker.service.

$ sudo systemctl start docker

$ sudo service docker status

● docker.service - Docker Application Container Engine

   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: e

   Active: active (running) since Sat 2020-10-03 21:28:48 EDT; 3s ago

     Docs: https://docs.docker.com

 Main PID: 11763 (dockerd)

    Tasks: 16

   CGroup: /system.slice/docker.service

           └─11763 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/contai


ref:

https://stackoverflow.com/questions/44678725/cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock-is-the-docker

Tuesday, 1 September 2020

Tinkering OpenWRT (20) : Flash Compiled Image

Step 1: 

After compiling, the bin file should be located in :
openwrt/bin/ramips/openwrt-ramips-mt7620-XXXXX-squashfs-sysupgrade.bin

Step 2:

Copy the bin file to board 
scp openwrt-ramips-mt7620-XXXXX-squashfs-sysupgrade.bin root@192.168.1.1:/tmp

Step 3:
Login board, ether via UART or Ethernet

Step 4:
cd /tmp
# make sure the file transfer is completed 
md5sum openwrt-ramips-mt7620-xiaomi-miwifi-mini-squashfs-sysupgrade.bin 
mtd -r write openwrt-ramips-mt7620-xiaomi-miwifi-mini-squashfs-sysupgrade.bin firmware

Wait for it to finish...

Friday, 7 August 2020

apt-get install stuck issue

I was trying to install nutstore but too bad it is discontinued and I am stuck at this error.

Setting up nautilus-nutstore (3.1.0) ...
fetching Nutstore distribution package...
--2020-08-08 01:21:23-- http://jianguoyun.com/static/exe/installer/nutstore_linux_dist_x64.tar.gz
Resolving jianguoyun.com (jianguoyun.com)... 13.75.93.73
Connecting to jianguoyun.com (jianguoyun.com)|13.75.93.73|:80...

The problem is, what ever new things I want to install, apt-get will end up stuck here.

Solution:
$ sudo apt-get remove nautilus-nutstore

Friday, 24 July 2020

To convert a bare repo to a normal one


To convert a bare repo to a normal one:
$ git clone -l <path_to_bare_repo> <new_normal_repo>

Friday, 3 July 2020

Tinkering OpenWRT (19) : HiLink 7866A Serial Login

I don't want to figure this out again, so here it is:

- Use COM0
- screen /dev/ttyUSB0 57600

Thursday, 30 April 2020

Install Ubuntu Dual Boot on Dell with SATA Harddirve

I was installing ubuntu on a new Dell machine with SATA. I booted into the Ubuntu Live USB but at the partitioning part I could only see /dev/sda which is just my USB drive. Where is my hard drive??!!

Here is the fix or prevention...so that you won't just change the SATA setting and lose windows. Then it will be a bit hard to fix.

  1. In Windows, run Command Prompt as admin
  2. Invoke a Safe Mode boot with the command: bcdedit /set {current} safeboot minimal
  3. Restart the PC and enter your BIOS during bootup.
  4. Change from IDE to AHCI mode then Save & Exit.
  5. Windows 10 will launch in Safe Mode.
  6. Right click the Window icon and select to run the Command Prompt in Admin mode from among the various options.
  7. Cancel Safe Mode booting with the command: bcdedit /deletevalue {current} safeboot
  8. Restart your PC once more and this time it will boot up normally but with AHCI mode activated.

Wednesday, 11 March 2020

Error "error: dpkg frontend is locked by another process"


sudo rm /var/lib//dpkg/lock
sudo dpkg --configure -a

ref:
https://www.ostechnix.com/how-to-fix-e-could-not-get-lock-var-lib-dpkg-lock-error-on-ubuntu/
https://www.youtube.com/watch?v=7GQIY37vPQ4

Toubleshoot Sogou Pinying Installing


sudo dpkg -i sogoupinyin_2.2.0.0108_amd64.deb

And got the following problem:

boris@boris-desktop:~$ sudo dpkg -i ~/Downloads/sogoupinyin_2.3.1.0112_amd64.deb
(Reading database ... 129112 files and directories currently installed.)
Preparing to unpack .../sogoupinyin_2.3.1.0112_amd64.deb ...
Unpacking sogoupinyin (2.3.1.0112) over (2.3.1.0112) ...
dpkg: dependency problems prevent configuration of sogoupinyin:
 sogoupinyin depends on libqtwebkit4; however:
  Package libqtwebkit4 is not installed.
 sogoupinyin depends on libopencc2 | libopencc1; however:
  Package libopencc2 is not installed.
  Package libopencc1 is not installed.
 sogoupinyin depends on fcitx-libs | libfcitx-qt0; however:
  Package fcitx-libs is not installed.
  Package libfcitx-qt0 is not installed.

dpkg: error processing package sogoupinyin (--install):
 dependency problems - leaving unconfigured
Processing triggers for libglib2.0-0:amd64 (2.56.4-0ubuntu0.18.04.4) ...
No such key 'Gtk/IMModule' in schema 'org.gnome.settings-daemon.plugins.xsettings' as specified in override file '/usr/share/glib-2.0/schemas/50_sogoupinyin.gschema.override'; ignoring override for this key.
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for shared-mime-info (1.9-2) ...
Processing triggers for fontconfig (2.12.6-0ubuntu2) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Errors were encountered while processing:
 sogoupinyin

Solution:
sudo apt --fix-broken install



ref:

Saturday, 22 February 2020

Android Studio ERROR: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

I was trying to import a project and I got the following error when building gradle:

ERROR: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

Solution:
- Find the file local.properties in ./app folder where gradle files like build and build.gradle live.
- Copy your local.properties file to the folder to the root folder where the project is stored.

ref:
https://stackoverflow.com/questions/27620262/sdk-location-not-found-define-location-with-sdk-dir-in-the-local-properties-fil

Tuesday, 19 November 2019

openCV Troubleshooting (2) : error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope


This is due to different versions of openCV. Things got update to different names.

Didn't work:
image1=  cv::imread("test.bmp", CV_LOAD_IMAGE_GRAYSCALE);

Didn't work:
image1=  cv::imread("test.bmp", IMREAD_GRAYSCALE);

WORKED!!!!!
image1=  cv::imread("test.bmp", cv::ImreadModes::IMREAD_GRAYSCALE);


ref:
https://stackoverflow.com/questions/27424285/cv-load-image-grayscale-is-not-definedpy
https://stackoverflow.com/questions/22547416/open-cv-flags-dont-work

openCV Troubleshooting (1) : undefined reference to `cv::xxxx`


I am compiling openCV project with cmake and I am getting errors like:

test.cpp:(.text+0xc0): undefined reference to `cv::imread(std::string const&, int)'
test.cpp:(.text+0x11f): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
test.cpp:(.text+0x138): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
test.cpp:(.text+0x158): undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
test.cpp:(.text+0x180): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'

The following compiling script won't cause the issue.
g++ -o test_1 test_1.cpp `pkg-config opencv --cflags --libs`

But to fix cmake compile, we need to add the following red line to CMakeList.txt.

cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )


ref:

Tuesday, 13 August 2019

Tinkering OpenWRT (18) : Toubleshooting MT7688AN Hardware




Problem (1) : Serial to TTL not working
     - Try use a laptop instead of a desktop. There might be compatibility issue between the motherboard and USB. Or just not enough power from USB on a desktop.
     - Try use a higher input than 3v3. Even 5v works.

ref:
https://blog.csdn.net/u012175418/article/details/52572672





Sunday, 14 July 2019

openCV Troubleshooting (0): error: (-215:Assertion failed) !empty() in function 'detectMultiScale'

Trying to compile some example code (in Python) from the internet and got the following error:

Traceback (most recent call last):
  File "main.py", line 16, in <module>
    img = drawFaces(img)
  File "/home/boris/facedetect_example/example2/OpenCV-demo-master/Video-FaceDetection/face_detection.py", line 26, in drawFaces
    faces = detectFaces(img)
  File "/home/boris/facedetect_example/example2/OpenCV-demo-master/Video-FaceDetection/face_detection.py", line 18, in detectFaces
    faces = face_cascade.detectMultiScale(gray, 1.2, 5)
cv2.error: OpenCV(4.1.0) /home/boris/workspace/opencv-4.1.0/modules/objdetect/src/cascadedetect.cpp:1658: error: (-215:Assertion failed) !empty() in function 'detectMultiScale'

It turns out the cascade XML or file is missing or the path to it is incorrect or the create_capture path is incorrect. Of course, this is someone else's code.

Updated this line:
face_cascade = cv2.CascadeClassifier("/home/aaaaa/OpenCV-demo/opencv-data/haarcascades/haarcascade_frontalface_default.xml")

To 
face_cascade = cv2.CascadeClassifier("/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml")

Everything works now.


ref:
https://stackoverflow.com/questions/30508922/error-215-empty-in-function-detectmultiscale

Sunday, 3 February 2019

KiCAD Tips -- 0 : How to Add a Footprint Library

I was still following the blinky example:
       https://contextualelectronics.com/topic/library-setup-and-part-association/

And it appears I don't have Housing SOIC footprint in my library. Here is how I solved it.

Step 1:
I couldn't find CvPCB anymore. But you can open it in EESchema, click


Step 2:
Preferences => Manage Footprint Libraries

Step 3:
Download your needed library from the following link:
      https://github.com/KiCad/kicad-library/wiki/Footprint-Libraries
I needed:
      https://github.com/kicad/Housings_SOIC.pretty

Step 4:
From the "Manage Footprint Libraries" Dialog, click "Browse Libraries..." and choose the downloaded file of the footprints.

Step 5:
You can notice the lists update in 5 seconds.



Friday, 1 February 2019

KiCAD Tips -- 0 : How to Add a Library

The following tutorial is awesome but like may other materials online, it is in KiCAD 4.0.
                      https://contextualelectronics.com/topic/creating-schematic-symbols/

The steps to create a new library and switch from the official library directory to the project directory to edit my own library are totally gone in KiCAD 5.0.2.

But eventually, I figured it out and it is actually easier.

Step 1: Click   to open the Symbol Library Editor.

Step 2: From the search tree on the left side, input device and select C. As described in the above tutorial, we are going to create our own library based on existing library. This capacitor is just a holder.

We can see from the above picture on the top bar, it is still pointing to the CAD's own library. But we want to customize it in our own project directory. 

Step 3: 
Click  to create a new library

Step 4: save the new library in your project


and 


Step 5: 
Now you can see it is added to your library tree.

But check out the top bar, it is still saying /usr/share/kicad/library...

Step 6: Right click myBlink => new symbol
Name your new component in this library:

Step 7:
Now the working directory has been set to your project and you can edit your component in your own library.













Monday, 14 January 2019

NO_PUBKEY Issue

Hit:21 http://ppa.launchpad.net/webupd8team/sublime-text-3/ubuntu xenial InRelease
Fetched 1,490 B in 1s (1,302 B/s)                 
Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://dl.winehq.org/wine-builds/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 76F1A20FF987672F
W: GPG error: http://download.opensuse.org/repositories/home:/emby/xUbuntu_16.04  Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0A506F712A7D8A28
W: The repository 'http://download.opensuse.org/repositories/home:/emby/xUbuntu_16.04  Release' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: Failed to fetch https://dl.winehq.org/wine-builds/ubuntu/dists/xenial/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 76F1A20FF987672F
W: Some index files failed to download. They have been ignored, or old ones used instead.

wget -nc https://dl.winehq.org/wine-builds/winehq.key && sudo apt-key add winehq.key && sudo apt update



boris@boris-home:~$ wget -nc https://dl.winehq.org/wine-builds/winehq.key && sudo apt-key add winehq.key && sudo apt update
--2019-01-15 00:43:38--  https://dl.winehq.org/wine-builds/winehq.key
Resolving dl.winehq.org (dl.winehq.org)... 151.101.126.217
Connecting to dl.winehq.org (dl.winehq.org)|151.101.126.217|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3220 (3.1K) [application/pgp-keys]
Saving to: ‘winehq.key’

winehq.key          100%[===================>]   3.14K  --.-KB/s    in 0s      

2019-01-15 00:43:38 (77.1 MB/s) - ‘winehq.key’ saved [3220/3220]

OK
Ign:1 http://linux.dropbox.com/ubuntu wily InRelease
Ign:2 http://dl.google.com/linux/chrome/deb stable InRelease                   
Hit:3 http://linux.dropbox.com/ubuntu wily Release                             
Hit:6 http://archive.canonical.com/ubuntu xenial InRelease                     
Hit:7 http://repository.spotify.com stable InRelease                           
Ign:8 http://download.opensuse.org/repositories/home:/emby/xUbuntu_16.04  InRelease
Hit:9 http://dl.google.com/linux/chrome/deb stable Release                     
Get:10 https://dl.winehq.org/wine-builds/ubuntu xenial/main amd64 Packages [145 kB]
Hit:11 http://ca.archive.ubuntu.com/ubuntu xenial InRelease                    
Hit:12 http://ppa.launchpad.net/fpoussin/ppa/ubuntu xenial InRelease           
Hit:13 http://download.opensuse.org/repositories/home:/emby/xUbuntu_16.04  Release
Get:14 https://dl.winehq.org/wine-builds/ubuntu xenial/main i386 Packages [151 kB]
Get:15 http://ca.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]   
Get:16 http://download.opensuse.org/repositories/home:/emby/xUbuntu_16.04  Release.gpg [481 B]
Hit:18 http://ppa.launchpad.net/gezakovacs/ppa/ubuntu xenial InRelease         
Ign:16 http://download.opensuse.org/repositories/home:/emby/xUbuntu_16.04  Release.gpg
Hit:19 http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu xenial InRelease
Get:20 http://ca.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] 
Hit:21 http://ppa.launchpad.net/webupd8team/sublime-text-3/ubuntu xenial InRelease
Hit:22 http://archive.ubuntukylin.com:10006/ubuntukylin xenial InRelease
Reading package lists... Done 
W: GPG error: http://download.opensuse.org/repositories/home:/emby/xUbuntu_16.04  Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0A506F712A7D8A28
E: The repository 'http://download.opensuse.org/repositories/home:/emby/xUbuntu_16.04  Release' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

boris@boris-home:~$ 


You can see the key issue from WinHQ is gone now.

###########################################################

$ sudo -i 
 # apt-get clean 
 # cd /var/lib/apt 
 # mv lists lists.old 
 # mkdir -p lists/partial 
 # apt-get clean 
 # apt-get update

sudo sed -i '/opensuse/ s/^/#/' /etc/apt/sources.list.d/*.list


Now the key issue from opensuse should also be gone.


ref:
https://askubuntu.com/questions/1103320/the-following-signatures-couldnt-be-verified-because-the-public-key-is-not-avai
https://ubuntuforums.org/showthread.php?t=1869890&page=3
https://askubuntu.com/questions/522114/cant-get-rid-of-gpg-error-http-download-opensuse-org


Tuesday, 1 January 2019

Troubleshooting when Setting up Github Page

At the step of setting up Ruby locally for testing, I got this:

Fetching gem metadata from https://rubygems.org/..............
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies.....
Fetching concurrent-ruby 1.1.4
Installing concurrent-ruby 1.1.4
Fetching i18n 0.9.5
Installing i18n 0.9.5
Fetching minitest 5.11.3
Installing minitest 5.11.3
Fetching thread_safe 0.3.6
Installing thread_safe 0.3.6
Fetching tzinfo 1.2.5
Installing tzinfo 1.2.5
Fetching activesupport 4.2.10
Installing activesupport 4.2.10
Fetching public_suffix 2.0.5
Installing public_suffix 2.0.5
Fetching addressable 2.5.2
Installing addressable 2.5.2
Using bundler 1.17.3
Fetching coffee-script-source 1.11.1
Installing coffee-script-source 1.11.1
Fetching execjs 2.7.0
Installing execjs 2.7.0
Fetching coffee-script 2.4.1
Installing coffee-script 2.4.1
Fetching colorator 1.1.0
Installing colorator 1.1.0
Fetching ruby-enum 0.7.2
Installing ruby-enum 0.7.2
Fetching commonmarker 0.17.13
Installing commonmarker 0.17.13 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/boris/workspace/my_Github_Website/codemonkeyboris.github.io/vendor/bundle/ruby/2.5.0/gems/commonmarker-0.17.13/ext/commonmarker
/usr/bin/ruby2.5 -r ./siteconf20181231-18337-kelz2o.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in
/home/boris/workspace/my_Github_Website/codemonkeyboris.github.io/vendor/bundle/ruby/2.5.0/gems/commonmarker-0.17.13 for inspection.
Results logged to
/home/boris/workspace/my_Github_Website/codemonkeyboris.github.io/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/commonmarker-0.17.13/gem_make.out

An error occurred while installing commonmarker (0.17.13), and Bundler cannot continue.
Make sure that `gem install commonmarker -v '0.17.13' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  github-pages was resolved to 193, which depends on
    jekyll-commonmark-ghpages was resolved to 0.1.5, which depends on
      jekyll-commonmark was resolved to 1.2.0, which depends on
        commonmarker

#####################################################

Solution:

$sudo apt-get install ruby-all-dev
$bundle install --path vendor/bundle


ref:
https://help.github.com/articles/setting-up-your-github-pages-site-locally-with-jekyll/
https://github.com/github/pages-gem/issues/133