July 2021

Programming Blue Pill STM32F103C8T6 with Eclipse and ST-Link V2 in Windows 7

Until today, I still could not find an all-in-one tutorial to program Blue Pill with Eclipse. I have been doing trial and error for weeks and have gathered what I have found into this single post. I hope it useful for anyone who setting up their Blue Pill with Eclipse.

Software and hardware requirements
1. Windows 7
2. Blue Pill STM32F103C8T6
3. ST-Link V2
4. Java 7 update 71 or later (I am using Java 8 update 291 for this setup)

ST-Link V2 and Blue Pill

Step 1 – Download Eclipse IDE for C/C++ here.
I download the ZIP archive and store it at a specific easily reachable location such as C:\STM32Toolchain\eclipse . In the later steps, all the packages and plugins will be added in C:\STM32Toolchain in order to manage it easily.

Step 2- Install CDT packages
In Eclipse, go to Help->Install New Software . Select CDT – https://download.eclipse.org/tools/cdt/releases/10.3, under CDT Main Features, select C/C++ Development Tools SDK

Step 2 – Install the GNU ARM plug-ins for Eclipse
Go to Help->Eclipse Marketplace.. . In the pop-up window that appears type “gnu arm eclipse” in the “Find” textbox and click on Go to kick off the search. The first entry found should be as shown, “Eclipse Embedded C/C++”. Click on install and follows the steps.

Step 3- Install the GCC ARM tool-chain
Download the  GCC tool-chain for the ARM Cortex platform here. You can download the installer and start the installation. When asked, install the tool-chain in the following directory C:\STM32Toolchain\gnu-arm\ . Leave unchecked the entry “Add path to environment variable“, especially if you have other compilers or IDE installed on your PC.

Step 4 – Install the Build Tools
Download the build tools here. When asked, install the tools in these folder: C:\STM32Toolchain\GnuWin32

Step 5 – Create an Empty Project in Eclipse
Go to File > New > Project…
Then select C Project. Select “Empty Project” & ARM Cross GCC. Specify the Project Name
Select Toolchain path

Step 6 – Copy the firmware library to the project directory
Download the STM32F1XX firmware library here. Place the library in C:\STM32Toolchain

Create a new folder [USER] and [startup] in the project directory

Copy the firmware library to the project directory

Copy below files in \test1\STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Template directory to the [USER] folder
a. main.c
b. stm32f10x_conf.h
c. stm32f10x_it.c
d. stm32f10x_it.h

Copy below file in \test1\STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Template\TrueSTUDIO\STM3210B-EVAL to the project directory (the file will be replaced)
a. stm32_flash.ld

Copy below file in \test1\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\TrueSTUDIO to the startup directory. Since I am using Blue Pill, the file is startup_stm32f10x_md.s . Rename this file to startup_stm32f10x_md.S
a. startup_stm32f10x_md.s

Copy the firmware library to the project directory. Delete Project and Utilities folders in \test1\STM32F10x_StdPeriph_Lib_V3.5.0 , at this point, the file addition and deletion is completed, select the project in the Eclipse workspace, and then right click test1 and select Refresh, the file will be automatically imported into the project

Step 7 – Define the project properties
Select the project test1 ->right-click->Properties->C/C++ Build->Settings
Select CROSS ARM C Compiler->Preprocessor. Add 2 symbols, USE_STDPERIPH_DRIVER, indicating the use of peripheral firmware libraries and STM32F103X_MD since I am using Blue Pill

Include the paths

Click the Toolchain tab and fill in the bin folder under the path of the installed cross-compilation tool

Add the path for Build Tools ( the GNUWIN32 downloaded earlier )

After that, set the linker file.

After that, modify the Main.c in the USER folder, because it does not contain any DEMO files, so you need to delete the function called under MAIN.C.

You might encounter “make” error. Go to Properties > Tool Chain Editor, select CDT Internal Builder

if you have error saying “Please select first the target STM32F10x device used in your application (in stm32f10x.h file)” , go to stm32f10x.h and select the device. Since I am using Blue Pill, the device is STM32F10X_MD.

if you encounter below error, open core_cm3.c under the project file \STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\CoreSupport and modify the code as shown below

Before
__ASM volatile (“strexb %0, %2, [%1]” : “=r” (result) : “r” (addr), “r” (value) );
__ASM volatile (“strexh %0, %2, [%1]”: “=r” (result): “r” (addr), “r” (value) );

After
 __ASM volatile (“strexb %0, %2, [%1]” : “=&r” (result) : “r” (addr), “r” (value) );|
 __ASM volatile (“strexh %0, %2, [%1]” : “=&r” (result) : “r” (addr), “r” (value) );

if you encounter “undefined reference to `_exit'” error, check whether you have define the correct linker file as in Step 7

if you encounter below error related to Reset Handler, make sure you have rename the file to startup_stm32f10x_md.S as in Step 6.

After that, you will be able to complete the code compilation.

Reference

https://www.carminenoviello.com/2014/12/28/setting-gcceclipse-toolchain-stm32nucleo-part-1/
https://www.programmersought.com/article/97124058587/ https://blog.csdn.net/u012523921/article/details/100774332
https://blog.csdn.net/Neutree/article/details/50551919
https://blog.csdn.net/u012523921/article/details/100774332
https://blog.csdn.net/u012523921/article/details/100736984
https://www.cnblogs.com/micro-st/p/8886566.html
http://www.jeh-tech.com/arm_eclipse.html

Is it hard to get a job in telecom industry in Malaysia?

I came from the technical part of this industry, so I will try to explain the telecom industry situation based on the engineering perspective. First, i will explain why it is hard to land a job in telecom and then what can be done in order to increase the chances to get the job.

There are many reasons why fresh graduates or experienced engineer find it hard to get a job in telecom. There are times when telecom are booming which creates a lot of jobs and there are times where no job can be found and one has to be patient and always keep on the lookout for opportunities. Furthermore in some countries, telecom jobs are rather limited since it depends on the scale of the network infrastructure and the population of the country as well. The more people are using it, the more it requires to expand the infrastructure. In Malaysia, the country is rather small, therefore the job opportunities are rather limited. Countries that have plenty of telecom jobs are countries where the telecom vendors (ericsson, huawei, nokia, zte, etc. ) set up their research centers. These countries requires a lot of engineers and they have the opportunity to learn highly technical skill and stay up to date with the latest telecom technologies.

As for other countries such as Malaysia, the nature of telecom work may be in the form of service delivery projects for telecom vendors and their subcontractors ( telecom vendors sub their project to these companies ) . Apart from that, several jobs can be found in MNOs (Maxis, Celcom, Digi) and in the telecom regulatory (MCMC) as well but the positions available are limited which requires applicants to compete with many other applicants to fill as little as one position. This situation happens when there are no new projects are running. But there could be a lot of opportunities when there is a big project until to some extend there isn’t enough manpower to run it. For example, in 2011, Digi invested a large sum of money to swap their 2G and 3G networks to ZTE equipment. At that time, there were hundreds of openings for engineer role in ZTE. Those were the good old days. Made a lot of friends, learned new things. Therefore, there are opportunities and one needs to stay alert on the latest telecoms news.

Reporting for duty at ZTE Malaysia (2011)

As I have mentioned ealier, telecom industry is a niche industry where only the ones who have worked in this industry knows about this industry. In other words, someone who have never worked in telecom industry won’t have the slightest idea about what telecom engineers do.

Drive test at klang valley area back in 2011

Therefore fresh graduates cannot burst into these profession easily because most of the things that they learned in the university cannot be applied into the job that they are applying. In order to increase the chances, one could focus his/her final year project on telecom research topics such as RF analysis, antenna design, optical performance analysis. Besides that, due to advancement in virtualization technology, one can simulate the whole LTE network by using desktop PC, SDR card, a sim card and a LTE smartphone. These options could boost the chances to get a job in telecom.

Simulate 4G network at home with Openairterface

Furthermore, it is easier to land a job with subcontractors since they normally hire fresh graduates because the nature of the work is more to installation and deployment which gives an opportunity for fresh graduates to learn the fundamentals of telecom technology before they can move up the career ladder into working with telecom vendors and MNOs. On top of that, one should always put him/herself in hiring manager’s shoes and think why they should hire him/her and not someone else.

Is China a backpacker friendly country?

i have been travelling to many countries and now working in China and although China is very safe but China is one of the country that is not backpackers friendly. The CCP’s dream is to monitor every people who lives in the country. When someone enters China, the CCP wants to know where you live, so you need to register yourself to the police station and some hotels does not accept foreigners, in fact in most outskirt areas, all hotels wont accept you. If these hotels have this kind of restriction, airbnb is worse and backpacker normally does not look for hotels, they look for cheap accommodation or couchsurfing. Even those chinese having a hard time to host you without having to face problems with the police. Eventhough CCP wants you to visit china, they only want you to visit the places that they WANT YOU TO VISIT. Some backpackers prefer to explore uncharted places, how can this be done when you can’t find a place to sleep? They have lots of nice places to go such as Xinjiang and Tibet. If you visit xinjiang, there will be security checkpoints all over the places. Would you want to waste your money to visit this kind of places? i went to Ningxia on a backpacking trip to visit a famous mosque located in a small village. I checked-in at the nearby hotel but after few minutes, 5 policemen came and I was brought to the police station for questioning for 3 hours. All my things were inspected, even the pictures and videos in my smartphone were inspected! imagine if you have a sensitive photos of your girlfriend/wife and suddenly a police get a hand of these materials. how do you feel? would you still want to backpack in China?

How China managed to control the COVID-19 outbreak in 2 months time?

i have been getting this question from my families and friends which made me decide to write my opinion after working in china for several years (before and after the covid-19).

as we all know, china successfully implemented mass surveillance on its citizens which means if you are a citizen of china, even your balls are being held by the government, in other words, the government knows everything about you and you can’t run away.

with this mass surveillance in place, it is easy to control the population when a pandemic like covid-19 exist. together with “no questions asked” policy, they can simply control the outbreak because the population is just like a ROBOT. why i said this because a robot does not question anything, and will do anything as instructed, everyone in that country follows what the government freakin told them to do! no one oppose the government ( and you know what will happen if they do ) .

secondly, in Shanghai, children are not allowed to attend religious classes. everyone obey this instruction. if the government can easily impose this autocratic rule, you can imagine how easily the government is able to impose rules to control the pandemic!

most people from outside china, are amazed when seeing this country “successfully” control the pandemic. some are proud and some criticize their own country, why their country cannot act like china. BUT they don’t know what it takes to achieve that kind of “success”.

if you live in a democratic country which is struggling to control this pandemic, you know democracy is not the problem, its the politicians. so do your part as citizens to voice your concerns. you have the power to make the country a better place. your life belongs to you, and it does not belong to the government!

Career in Huawei Technologies Malaysia

Someone asked a question and i thought it would beneficial to share it here.

Question:
Hi there… Just wanna to ask you some opinion regarding Huawei. Im a fresh graduate got offered with project management engineer position in HW, been reading alot of the comments on the Huawei’s thread, and most of the comments are quite scary, is it really that “bad” though?
The contract position is kinda risky as well… actually i got offered with another permanant position in other company, but for the jobscope i prefer huawei as i intended to debut my career in project management. i heard the politics are very “legendary”. Just wanted to hear your thoughts on it

Answer:
Firstly, congratulations on getting both jobs.

Malaysia’s 5 main industries are banking, ecommerce, OnG, construction, electronics/manufacturing and IT. IMO, everyone has a dream career but in Malaysia, we cant just blindly follow our dream. As an example, I want to become automotive engineer, unfortunately Msia doesn’t have a good automotive company to grow my career to become a true automotive engineer. We used to have a good auto company (Proton) but now not anymore. Even working in Perodua is a waste of time because there is no r&d opportunity since they just copy all the design from Toyota/Daihatsu. End up become Copy Engineer. Somemore, they pay peanut salary but we work 8 hours per day just like everybody else. Why waste our time working like this? Get my point?

What I’m trying to say is to look for a job in an industry where money is abundant or work in Fortune 500 companies where they have cash to pay a good salary. DONT find a job that you like but FIND a job that you like AND it pays a GOOD MONEY.

Maybe my comments about Huawei are a bit exaggerated but its better to be ready for the corporate world. Companies are not doing charity work. They are trying to make money and the fresh grad is an easy target for them to gain more for what they paid for. Huawei or any companies, in front of u, they will say all the nice words such as “Employees are our precious assets”, but in reality is, they will question whether your salary is justified with the work that u delivered. No hard feelings. Its just business. It’s a cruel world. But I don’t deny that there are some companies who truly value their employees such as companies listed in Fortune 500 such Microsoft, Apply, Google, Cisco etc.

despite the negative aspect of this company, Huawei is a very good place to grow but it is definitely not a good place to stay for a long term basis. And it is still much better than to work in most of the local companies. working in an MNC, u get the chance to hang around with great ppl with great mindset and with vast experience which enables u to grow, not just for your career but to broaden your way of thinking, the way u see things, let u see things differently as compared to other typical ppl. that’s why there is a saying “Your Circle of Friends Influence Who You Become”. so, if u hang with ppl who always play politics, talk c*ck, day dreaming, you will definitely become just like them.

Career in project management is not bad actually. you have the opportunity to grow as Project Mgr, then become Director, after that C-Level etc. I assume you have an idea about your career goals, what u expect to become in 5 years time, 10 years time, etc. Huawei is one of the biggest company in the world, definitely u have the opportunity to gain experience. It is much better if this role have the opportunity to work abroad or collaborate with international peers globally. By looking at the JD, u will handle the project mgmt system, but I am not sure the detail of this role. But normally in Huawei, most of their Project Managers come from a technical background, where they have worked as Engineer doing technical stuff. So, for u to start your career directly in Project Mgmt might give u an extra challenge to equip urself in technical area for career growth. But I might be wrong, but u can give it a try and see what this role has to offer. Learn as much as u can, don’t learn some basic stuff, but gain some unique knowledge where u can use it to boost your career. For example, getting involved in a big project, where time is critical, and so on. Honestly I don’t know much about Project Mgmt team because I joined them as Technical Engineer where in my field of work, there is a huge potential for career growth since it involved working with the latest tech such as 5G and this knowledge is highly in demand in many countries but not in msia because telco have limited opportunity eventhough it is a lucrative business.

why worry about office politics? firstly, what is your goal when joining huawei or any other company? if your aim is to gain bonus, promotion, increment, i guess by playing politics will help u achieve these goals. if your aim is to gather unique knowledge and skills as much as possible so that u can jump to a better company with a better pay, office politics are irrelevant to u. yes, salary is super low for fresh grad, but looking at the bright side, there is an opportunity to gain priceless knowledge which will leverage the money issue. therefore its a win-win situation, the company hired u cheaply and in return, u get to learn something priceless. remember, “DO NOT work hard, but work SMART!” “DO NOT be loyal to the company, BUT be loyal to your CAREER!”

and I suggest u to keep on applying for other jobs at a good company. You are still young. If u haven’t figured out your passion, keep on working in different company until u find the right one. Because passion will drive your career, which in return will reward u with money, promotion, bonus, etc.