.. index:: rants, rant:reinventing the wheel, rant:the library myth, nucleo-stm32l072, mbed, mbed:blinky code, forth:blinky code, assembly:blinky code, ttm richter,c programming language .. _rants: Rants ===== Here is where I try and explain why some things BUG ME. .. note:: Disclaimer: I may not be right, I may not be wrong, these are my opinions and no one elses. .. _ttmrichter: I'm inspired by the epic rants of ttm richter --------------------------------------------- I met TTM (Michael) Richter on IRC a few years back. A Canadian of Teutonic roots who lives in China, he's a wordsmith, teacher and programmer who seems to love all types of software (including Forth), has strong opinions and can express them in the most entertaining ways. I have Michael to thank for suggesting the Fossil Software Code Management system and many other helpful tips that have made my own software journey easier and smarter. Rant about github "linguist" program failures ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :: Jesus! Could you please just SHUT THE FUCK UP ABOUT MAKE?! The issue here is how Linguist sucks so strongly that it can extract matter from galactic black holes. This is an issue which has been outstanding for over a year ON THIS SINGLE FUCKING LANGUAGE ALONE. I'm sure if we scanned other PRs we'd find more that are even older. (Like .pl and Prolog which I highlighted above.) The code, as it is now, IS NOT CORRECT. The code, as it has always been, HAS NEVER BEEN CORRECT. The code, IS DEFECTIVE BY ITS VERY DESIGN. If you really do believe that correctness is paramount ALL of your diarrhetic verbiage about performance is disingenuous, meaningless drivel. (It's meaningless drivel if you don't believe that correctness is paramount, but at least it's honest diarrhetic verbiage.) So which is it? You can't have it both ways. [ttmrichter]_ .. _solve_stm32_problems: How to Solve STM32 Problems --------------------------- * Read the reference manual for an hour * Verify it doesn't work as it should * Curse * Read the reference manual for 10 hours * Try everything * Accept the fact you still don't understand what the hell is going on and try harder * Use Forth to explore a wide range of tests, verify the results with assertions * Finally understand what is required and wonder why the hell you didn't 'get it' the first time * Wish you were smarter ... ... at least that's my experience .. _rant-blue-pill: .. index:: aliexpress,alibaba,counterfeit,bluepill, blue pill, fake STM32F103 chips QUICK, GRAB A BARGAIN --------------------- .. _bluepill: Bluepill PCB ^^^^^^^^^^^^ .. image:: pics/blue-pill.jpg **Find out if your Blue Pill chip is a genuine** :ref:`STM32F103` **Update Feb 2021** It's been a few years since I wrote this article and a lot has changed in that time. Some of the STM32F103C8 clones such as the GD32F103 and the CS32F103/CKS32F103 have become mainstream and now appear in some Chinese products with their manufacturer part numbers. The Blue Pill Boards are also more expensive now with the cheapest I could find on eBAY today (15Feb2021) being US $4.09 with free shipping from China. https://www.ebay.com.au/itm/STM32F103C8T6-ARM-STM32-Minimum-System-Development-Board-Module-For-Arduino-1pcs/312108964016?hash=item48ab24d8b0:g:luYAAOSwrhlazxC- But there are still a couple of very good reasons for buying these cheap Bluepill boards: 1) :ref:`Make a Black Magic Probe` 2) :ref:`Make a SWD/USB programmer` A Bargain? ---------- I just don't get people who think that the :ref:`"Blue Pill"`, a "development board" based around the STM32F103 from China for $1.50 is a bargain. I can't even buy a cup of coffee for under $5 nowadays. When I was in my early 20's, a National Pace 16 bit CPU was $270. A new 8 bit Motorola 6800 was about $170, and both of those CPU's needed extensive support devices because they had zero peripherals. When the 6502 (with a limited 8 bit index register) came out for $15 it was lapped up by generations of people who also thought it was a bargain. The STM32F103 is a *OLD chip* based on the first generation of Cortex M3 chips announced in 2004, and manufactured since at least 2005. They have a lot of :ref:`known problems`. A much better choice for new projects are either STM32F0, F0+ series or STM32F4 series. The prices are about the same for comparable parts. Breaking Copy Protection ^^^^^^^^^^^^^^^^^^^^^^^^ Your firmware isn't safe either in this chip, see https://blog.zapb.de/stm32f1-exceptional-failure/ Then there is also the **COUNTERFEIT** issue ... Counterfeit ^^^^^^^^^^^ https://www.stm32duino.com/viewtopic.php?f=7&t=127 A Chinese engineers attitude about what I call 'counterfeit'. Part numbers are not generally considered trademarks here. If I produce a transistor that adheres to all 2n3904 specifications, I can sell it as a 2n3904, even if some characteristics not on the datasheet are a bit different. Similarly if I make a chip that functions just like a STM32 and runs most code unmodified (except maybe for very few corner cases), it's generally considered a-ok to sell it as a STM32. The generics mindset here is strong, and it's not considered ok for one manufacturer to monopolize a part number, especially when compatible substitutes are produced. "STM32" is a generic name for a MCU with these peripherals in this layout, just like U.FL is a generic name for a connector with these dimensions. If that's a problem for you just buy from the big distributors. Aliexpress refuse evidence and refund ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. image:: pics/aliexpress-conterfeit-stm32f103.jpg ST Micro letter verifies counterfeit ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. image:: pics/counterfeitstm.jpg Counterfeit Incompatabilities ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Anolog Read Issue ~~~~~~~~~~~~~~~~~ https://www.stm32duino.com/viewtopic.php?p=865&sid=4691deba3946368120f63923a877f10a#p865 .. image:: pics/counterfeitstm-differences.jpg .. seealso:: :ref:`What chip is actually in your Blue Pill and how much Flash does it have ?` .. seealso:: :ref:`STM32F103C8 V/S GD32VF103Cx` .. seealso:: :ref:`Blue Pill Starter Kit` .. _stm32f103-limitations: Some STM32F103 Problems ^^^^^^^^^^^^^^^^^^^^^^^ .. literalinclude:: txt/stm32f103-limitations.txt Known Blue Pill Issues ^^^^^^^^^^^^^^^^^^^^^^ * R10 is often the wrong value. The USB standard require a 1.5k pull-up resistor on D+, but this board is known to have a wrong value with either a 10K resistor or a 4.7k resistor fitted. Google "R10 Blue Pill" for more information. * Header pins are rubbish and they rust easily. Experienced Blue Pill users throw them away and use gold plates header pins, which doubles the cost of the $2 board! * USB socket breaks off easily being poorly attached. Experienced Blue Pill users add extra solder etc. * Fake MCU. These can be: * Relabelled STM units with less memory, i.e. 32kB or even 16kB Flash * Clones such as the GD32F103 or CKS32F103C8T6 (whatever that is) * No serial bootloader is present meaning you have to use SWD or JTAG to program them. *Now just think for a minute*, a new STM32F103RBT6 is today is priced at $4.525 each in quantities of 100 from Arrow.com, so how is it possible that a Chinese vendor can sell you one in a PCB with switch, option jumpers, USB socket, two crystals and a voltage regulator for $1.50, what's wrong with this picture ? Genuine STM32F103C8 Decapped ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Copied from https://www.richis-lab.de/STM32.htm .. image:: pics/chip-pics/stm32f103c8-genuine-decapped.jpg For a list of known Chinese clones of various STM chips :ref:`see this page` CKS32F103C8T6 Decapped ^^^^^^^^^^^^^^^^^^^^^^ The "CKS32F103C8T6" is a fake it is not even listed on the CKS product website. Its a fake because it counterfeits the STM32 ID's and name internally. Copied from https://www.richis-lab.de/STM32.htm .. image:: pics/chip-pics/cks32f103103c8t6-decapped.jpg Using the CKS32F103C8T6 isn't always straightforward either as this user found: :: I`ve got chinese clone CKS32f103c8t6 Blue Pill board with ST-LINK V2 (cheap clone again).I`m able to flash .hex file with ST LINK Utility software but I`m not able to use it with CubeIDE.Here is what I get when I press Debug Button: Open On-Chip Debugger 0.10.0+dev-00021-g524e8c8 (2019-07-16-09:47) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html none separate Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD adapter speed: 240 kHz adapter_nsrst_delay: 100 Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : clock speed 240 kHz Info : STLINK v2 JTAG v34 API v2 SWIM v7 VID 0x0483 PID 0x3748 Info : using stlink api v2 Info : Target voltage: 3.201053 Info : Stlink adapter speed set to 240 kHz Warn : UNEXPECTED idcode: 0x2ba01477 Error: expected 1 of 1: 0x1ba01477 in procedure 'init' in procedure 'ocd_bouncer' I`ve found that, some solved that issue by pasting this line to the some .cfg file on platformio IDE. set _CPUTAPID 0x1ba01477 How could be this done on cubeIDE? Blue Pill with a CKS32F103C8T6 chip ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This chip is actually a CKS32F103C8T6 Blue Pill is like a box of chocolates ************************************* .. image:: pics/blue-pill-fake-stm32f103c8.jpg Then you have the Chinese 'cheap USB to SWD programmers' some of which don't implement ST-Link properly. These also cost a couple of bucks and are usually bought with the 'bargain' $1.50 'Blue Pill' because it is the only way to get in-chip debugging (usually used with GDB). Update 2020: I see that some of the cheap Chinese ST-Link programmers now come with a CKS32F103C8T6 and update online with using the proper STM firmware! .. _chinese-st-link-clone: .. image:: pics/chinese-st-link-clone.jpg GD32F103C8 Decapped ^^^^^^^^^^^^^^^^^^^ The GD32F103C8 is a bonafide STM32F103 "compatible" chip, it advertises its own ID, make and manufacturer identification internally. GD are a reputable and innovative manufacturer as far as I know. GD32F103C8 Cortex-M3 die with serial flash; copied from https://zeptobars.com/en/read/GD32F103CBT6-mcm-serial-flash-Giga-Devices .. image:: pics/chip-pics/decapped-GD32F103CBT6.jpg Summary ------- I say cut the pain, make your time count and buy a new :ref:`STM Nucleo` or :ref:`Discovery Board` with the latest feature packed STM32M0, M0+ or M4 chip, a USB to SWD programmer/debugger is included for free, they aren't expensive and the smaller Cortex-M0+ can be had for $15. That way you will be learning and benefiting from the latest tech, not old tech. And it's guaranteed to work, unlike that $1.50 'Blue Pill'. .. note:: I have no connection with STM or any company, and receive no monies of any kind from any manufacturer or supplier, I use STM32 micros based on their ease of use and capability. If they were $20 a chip, I'd still consider them incredibly cheap. Finally, some great articles on STM32 clones. https://www.rogerclark.net/gd32f103-a-stm32f103-on-steroids/ https://olimex.wordpress.com/2015/11/09/chinese-clones-attack-stm32-microcontrollers/ .. _invent-wheel: REINVENTING THE WHEEL --------------------- I BUGS ME every time I read the comment **"why should we reinvent the wheel?"** usually by a non Forther commenting on the lack of Forth libraries and how they have tons of libraries for Arduino or Mbed or whatever. The implication is that these Libraries allow use of hardware that the C developer knows nothing about, thereby avoiding days or weeks studying datasheets until intimately familiar with the device. OK, lets look at the WHEEL, who here has actually EVER made a REAL WORKING WHEEL ? ... anyone ? One big fault in logic is thinking "Mankind has invented the wheel, and I'm a part of Mankind, so I'm a part of that". No you're not, unless you have actually invented your own wheel, you don't have a clue, you only *think* you do! My Dad once made a kid sized motorized Go-Cart and the wheels. The wheels were about a foot high and 8" in width. The wheel itself was rolled circular steel plate with a gap that accepted the ends of a 8" wide strip of tyre tread rubber which was tightly pulled around the rim before being locked in place in that gap. The wheel had welded steel spokes from rim to hub and each wheel could probably take a ton of weight. They were painted in silver paint. I recall my Dad showing me the 'secret' to cutting the wide strips of rubber tread from bald tyres for the Go-Cart wheels, "the secret Terry", he said "is to use a sharp knife and do it under *running water* and it cuts like butter". And so it does. The Go-Cart was a fantastic success with the small lawnmower engine that powered it. It had working brakes and did I mention it had a *engine* ? Many a glorious after school evening was spent in that machine as we kids did broadside after broadside at the end of our loose gravel driveway. Until my Mother got involved ... She didn't care about the broadsides, the dust we raised, the noise of the engine, the fuel we burned or the lack of seatbelts, this was around 1960 and Mum knew boys were tough, if we hurt ourselves she'd apply a bandage or calmly take us to the local doctor. No it was *Dads wheels* that were the problem. What she couldn't abide were "home made wheels", they were *unsightly* she claimed and berated my Father that her children deserved better. Mum didn't have a clue about wheels, their load ratings, their strength and durability. She only knew wheels as a consumer who thinks prettier is better. Dad, being a wise man knew my Mothers mind once set, could not be changed and dutifully purchased expensive pretty white smooth plastic wheels with inflatable tyres and replaced the wheels on the Go-Cart. They may have been wheelbarrow or trolley wheels I don't know. They lasted exactly one broadside, and produced a loud CLUNK. I was astounded to see a pretty new white wheel with inflatable tyre heading off down the street on its own. Yes, the plastic wheel had torn right off the hub which remained attached to the axle while the wheel and tyre made their dash for freedom. That was the last time we drove that fantastic machine, Dad had blown his budget on the pretty plastic wheels (which were no good anyway) and Mum wouldn't allow "Those Wheels" back on the Go-Cart. I pleaded and pleaded for the original wheels in vain. Due to the psychological ramifications of this cruel and unusual child torture, when I grew up I became a motorcyclist instead of a car driver. Two of Dads home made Go-Cart wheels went into a heavy electric arc welder cart and 50 years later are still rolling that welding machine along smoothly. So Whats The Point Here ? ^^^^^^^^^^^^^^^^^^^^^^^^^ My Dad *really* knew how to make wheels because he invented some. Knowing my Dad invented wheels does not help me. To truly understand wheels I must invent some of my own. * **Inventing the wheel is the best form of learning and the sooner you start the sooner you finish because there is no shortcut** .. _c: THE C PROGRAMMING LANGUAGE -------------------------- When it comes to Embedded Electronics just ask Agent Smith what he thinks about C ... .. image:: pics/matrix-plague-scene-sml.jpg C is Bare Metal? ^^^^^^^^^^^^^^^^ C users often claim that "C is low level, it's at the bare metal" which is a interesting claim for a language that does *not support a "bit" type*. Compilers that do have it, use nonstandard extensions. You can use bitfields to pack flags, but they can produce rather inefficient code. :ref:`Ttmrichter` Comments on the 'C' Language I absolutely despise C Basically, though, my stance is that C, whenever it faced a trade-off between writing code and maintaining code, chose the one that optimized the writing of code. They systematically chose, whenever there was a design choice point, to make the default behaviour "fuck maintenance". Which is why we have a language without arrays, say, just (lousy) syntax sugar that sorta/kinda approximates arrays among a myriad of other such flaws. But hey! We can copy strings from one place to another with "while (\*dest++ = \*src++);"! As long as we don't care about security! Or accidental overlaps! Or memory order sequencing! Or a million other things that matter in the real world, but make for code that doesn't look so spiffy and cool! It's also why we have a language without any meaningful sense of modularity. Why the language had to get littered with so many stupid things like the "volatile" keyword. Why we have a language that has no meaningful constants. Online C examples are useless ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ One of the big advantages touted for C is "Information hiding", claimed to be a powerful programming technique because it reduces complexity. Unfortunately this means C code examples are all but useless for a Forth programmer, because we need *all* the information to understand what is going on, but no one ever bothers to list their C header files etc. * Even STM use The C Language To explain how their hardware works as tho C is the language of hardware. Example 1 ^^^^^^^^^ https://community.st.com/s/question/0D50X00009XkgyKSAR/stm32f0-sleep-mode "My following program blinks the LED using systick timer, while after ten times blink the LED the MCU should goes to sleep mode" .. note:: Sleep mode is trivial in Forth, but I'm mystified where the WFI command is hiding in this example C code. :: #include 'stm32f0xx.h' #include 'stm32f0xx_tim.h' #include volatile uint32_t msTicks; void gpio_init(){ GPIO_InitTypeDef GPIO_InitStructure; RCC_AHBPeriphClockCmd (RCC_AHBPeriph_GPIOC | RCC_AHBPeriph_GPIOA,ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_8 ; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOC, &GPIO_InitStructure); } void blink_LED(){ if (msTicks == 1000){GPIOC->ODR ^= GPIO_Pin_8; msTicks = 0;} } void SysTick_Handler (void) { msTicks++; // Increment counter } int main(){ SysTick_Config (SystemCoreClock/1000); // Configure the SYSTICK gpio_init(); while(1){blink_LED();} } As a Forth user living in a C World, even the title of the example annoys me. It's not a *program* it's a *'C' program*. To learn about STM32F0 Low Power Modes from this 'example C program' I need *all* the source, which is not provided or linked, for the files listed below :- * stm32f0xx.h * stm32f0xx_tim.h * the full details of various *_InitStructure* These kind of issues mean it's rarely worth my time decoding a C "example", tracking down the header details etc. It's faster to go directly to the STM datasheets and programming reference manuals and just experiment in real time on the hardware itself. .. note:: As an aside, I often observe that online C "examples" are just copy and paste of someone elses example code, complete with the same errors. I believe that the C Programming Language is so popular in Embedded because thousands of free libraries promise to do what the programmer wants whilst alleviating the need to actually understand the process. C Users ^^^^^^^ Some C users are just not interested in learning. One *never* sees this kind of stupidity amongst Forth users. Example ~~~~~~~ In December 2019 I created a free self bootable binary image with a menu for :ref:`testing the STM32F103C8` All anyone has to do is flash the image to a STM32F103C8 and from a serial terminal run the menu. A child could do it, but not Doctorandus_P apparently. :: Date: 08.01.2020 From: Doctorandus_P I did not spend much time on this, as I'm not interested in binary blobs, but still had a look... Then I saw it was soe FORTH thing, and that done it, closed the website. I don't have anything against FORTH, but I am simply not interested in learning yet another language. .. note:: There is NO OTHER stm32f103c8 diagnostic bootable binary :ref:`image` available to my knowledge (@ Jan 2020), certainly nothing produced by any C user and made freely available. Fortunately there are plenty of smart, polite and helpful C users on that same forum. In fact it was bingo600 who told me about the stm32f103c8 "hidden flash". :: Date: December 15, 2019 From: bingo600 Message: @techman-001 Nice test :-+ ... Now to avoid those bluepill's on Ali/*bay Thnx /Bingo .. _library-myth: THE C LIBRARY MYTH ------------------ Lets be perfectly clear here: Libraries in C++ (and in C of course) are just a joke. There's no such thing as a library actually. They are just piles of definitions and functions/methods stacked together. Those non-Forthers who think it's not necessary to read every page of a STM32xxx manual because they have "libraries" that will do the job instead are really just strapping on pretty plastic wheels which will snap off at some point. Why ? Because they don't know what's in the library. If they can't be bothered reading a technical manual, why do you think they will be bothered scrutinising every line of someone else's monster complex library code ? Even a "low end" STM32F051 contains 37 Peripherals, 413 Registers and 3044 Register Bitfields, do you really think that anyone is going to write a Library that encompasses every permutation, for free, this century ? .. note:: Mbed is my poster child for the Great Library Myth in this article, but it could just as easily be Arduino or Atollic Studio. .. _index: web ide, web blinky, mbed Nucleo-STM32L072 on MBED ^^^^^^^^^^^^^^^^^^^^^^^^ Recently I used Mbed with a Nucleo-STM32L072. It's probably the easiest method ever to get a board running as nothing is actually installed on the host PC other than the completed project binary downloaded from your Mbed cloud page and flashed to the Board MCU when it's Dragged and Dropped into the Board bulk storage USB filesystem. It has a number of code projects available for download which also make extensive use of libraries. https://www.mbed.com/ Forth ~~~~~ I selected the traditional *Blinky* project and the Board led was flashing in 30 seconds ... easy peasy. Sadly I didn't have any idea about the actual blinky, how was the wait() function implemented, blocking spinner or interrupt ? What GPIO does myled() actually drive ? However my biggest WTF! was the binary size of 26,076 Bytes. I can fit a whole interactive Forth OS in 19,000 bytes, and a Forth blinky in another 82 bytes. That's 6994 Bytes LESS ! Assembly ~~~~~~~~ I can make the same Blinky in NON-INTERACTIVE Assembly code (see below) in 76 bytes. It's cold bootable and completely self contained. Thats 26,000 bytes less than the NON-INTERACTIVE MBED code and 19006 Bytes less than my INTERACTIVE Forth code. Mbed Blinky Code ^^^^^^^^^^^^^^^^ :: #include "mbed.h" DigitalOut myled(LED1); int main() { while(1) { myled = 1; // LED is ON wait(10.0); // 10 sec myled = 0; // LED is OFF wait(10.0); // 10 sec } } Binary file size = 26,076 Bytes. Forth Blinky Code ^^^^^^^^^^^^^^^^^ :: \ The led is connected to GPIO Port C, bit 9 : half-second-delay 400000 0 do loop ; : green-led.on %1 9 lshift GPIOC_BSRR bis! ; : green-led.off %1 9 lshift GPIOC_BRR bis! ; : blink %01 18 lshift GPIOC_MODER bis! \ Make GPIO Port C, bit 9 a OUTPUT do green-led.on half-second-delay green-led.off half-second-delay loop ; Binary file size = 82 bytes Assembly Blinky Code ~~~~~~~~~~~~~~~~~~~~ :: // Minimal assembler blinky example for stm32f051 // Requires svd2as // Board: stm32f0 Discovery // Blue LED is on GPIOC bit 8 // 8th June 2018 Copyright Released under the GPL .cpu cortex-m0 // Tell the assembler what model of CortexM this is for .thumb // Cortex micros only understand thumb(2) code .text // what follows is code .include "bitposn-equates.s" // a list of ".equ BIT0, 0x00000001", ".equ BIT1," etc .include "STM32F0xx.svd.s" // Compliments of svd2gas .syntax unified // use newer style instructions Vector_Table: .word 0x20000000 // stack pointer value when stack is empty 0x20000000 ResetVector: .word start + 1 // Reset Handler start: ldr r1, = RCC_AHBENR ldr r2, = RCC_IOPCEN // Turn on clock for GPIOC str r2, [r1] moder: ldr r1, = GPIOC_MODER movs r2, 0b01 // Set GPIOC-8 to output lsls r2, GPIOC_MODER8_Shift // BitWidth 2 str r2, [r1] // Main Loop led_on: ldr r1, = GPIOC_ODR ldr r2, = BLUE_LED_ON // Turn LED on str r2, [r1] ldr r0, = DELAY // delay delay_1: subs r0,r0,#1 bne delay_1 led_off: ldr r1, = GPIOC_ODR ldr r2, = BLUE_LED_OFF // Turn LED off str r2, [r1] ldr r0, = DELAY // delay delay_2: subs r0,r0,#1 bne delay_2 b led_on // branch main_loop constants: .equ DELAY, 0xfffff .equ BLUE_LED_ON, GPIOC_ODR8 .equ BLUE_LED_OFF, 0x0 Binary file size = 76 Bytes. Size of Binary Files ~~~~~~~~~~~~~~~~~~~~ =========== =================================== ========================================================================== =============================== OS Binary file size (bytes) Notes My Trust Rating (0-10) ? =========== =================================== ========================================================================== =============================== Mbed 26,076 spinner delay, non blocking, interrupt ? I don't know, the doc doesn't say 0.5 Forth entire Forth OS = 19kb + 82 bytes blocking spinner delay 10 Assembly 76 blocking spinner delay 10 =========== =================================== ========================================================================== =============================== .. _windows-ordie: USE MICROSOFT WINDOWS OR DIE ---------------------------- .. image:: pics/confickerreadybadges.jpg It's always BUGS ME when I read statements like "you have to interface with Windows or die" because when I was doing datacomms in 1985 the entire corporate world was IBM AIX, Silicon Graphics IRIX, Sun Microsystems SunOS, Hewlett-Packard HP-UX, DEC VMS etc ... Universities were all Unix. I remember seeing Windows 3.0 one day at work and all the engineers thought it was a joke, some child's toy. Like *MSDOS* (upon which it depended) it didn't even have native networking which came via a TSR that used the CMU TCP/IP stack because Bill Gates apparently thought that the Internet wasn't useful. I've always seen *MS Windows* as *White Goods Software* for the masses where "next years version" will have the egg timer you've all been waiting for. I've watched *MS Windows* slowly spread like a cancer, driven not by any technical prowess but by cheap pricing, shark like salesmen and illegal market practices. *MS Windows* did bring some unique features to the corporate marketplace eventually however, people who took Unix yearly uptimes for granted were introduced to Windows BSOD's, and Unix security was replaced by Windows only Viruses and Trojans. Sure *MSDOS* was cheap and enabled me to run PADS and ORCAD at work, both very good programs and very fast, even on the glacially slow PC's we had back then. Before *MSDOS* one needed a massively expensive Unix server and software for enterprise multilayer PCB CAD design, because that was *all there was*. Tektronix used to sell complete systems for PCB CAD, I remember seeing one at the local Tektronix office and I was mesmerized by the capability and the unbelievable cost. What do you think the GE turbine design and CAD storage systems ran in the early 80's, what did engineers use to fab all the TTL chips, Z80's, 6502's ? It sure wasn't *MSDOS* or Windows. Autodesk's Maya software is one of the most popular 3D animation packages in the history of the craft but it was made by Silicon Graphics and ran on Unix before Autodesk acquired it. Now before you go on about Autocad, in 1990, General Dynamics Electric Boat Corp chose CATIA as its main 3D CAD tool to design the U.S. Navy's Virginia class submarine, and CATIA which originally ran on mainframes, was moved to Unix in 1988. CATIA didn't run on Windows NT until 1998. Linux did have a big effect on the small one man hitech business I owned and ran for 14 years. I did schematic capture, pcb cad, 2d cad, document processing, accounting, video surveillance and everything else I needed without any kind of *MS Windows*, but the main effect that Linux had was the competitive advantage it gave me over my competition. I did things the competition couldn't imagine and couldn't afford and I did it FAST with all the tools they didn't have. Sometimes I actually felt guilty, why should my life be so easy and theirs so hard ? While I was writing Perl and Sh scripts to do automated configuration and testing of WiFi P-P links, they were still trying to work out why their Windows XP laptops needed a reboot after a IP change. Why did IBM recently pay $35 BILLION dollar$ for Red Hat Linux ? With that kind of money why didn't they buy the awesome Windows 10 instead ;-) Now I know the Windows diehards here will be swallowing their tongues, turning blue and harrumphing all over the place by now, but at 64 years of age, I could care less, and leave you with the following observations. There is no such thing as Windows admin, there is only the *Windows Bandaid Kit* that the more advanced Windows users apply to the festering sores that grow on a OS they can never really understand while referring to the "Windows advanced book of 3001 Secrets" they have to use for a manual. Real admin is only possible for Unix, most commonly Linux, and it takes TEN YEARS of daily use to become a competent Unix Admin, there is no shortcut, the sooner you start, the sooner you will arrive. .. _water-baron: The Water Barons ---------------- Written 8th June 2019 *A water baron is a person or organization that manages to gain dominant control over the water supply in an area* I'm very lucky, I was born in the 1950's, a post war time of peace, at least in Australia. My Father and Uncles who were all in the Army survived and so I benefited from their skills and experiences as I grew. Get Them When They're Young ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Around the age of nine I became obsessed with electronics after a kid at school gave me a pristine edition of the 1954 "ARRL Handbook". I would spend the rest of my life learning, experimenting and working with electronics as a result. Thank you Johhny Coghlan. Kids Are Always Broke ^^^^^^^^^^^^^^^^^^^^^ As a nine year old I didn't have any money to fund purchases of cool MCU development boards from Amazon or AliExpress, in fact none of those things existed back then and everything electronic used "Valves" because although Brattain, Bardeen and Shockley of Bell Labs had invented the transistor some 20 years before I was born, they were not yet found in common household devices like radios and televisions. The 1954 "ARRL Handbook" was all about using Valves, making 300 - 10,000 volt power supplies, constructing the chassis, wiring, soldering, loom forming, coil winding, everything a young electronics enthusiast needed to obtain valuable hands on electronics skills. But reading is one thing, doing is quite another. How Designers Are Made ^^^^^^^^^^^^^^^^^^^^^^ Back then the local council *Rubbish Tip* "Tip" was my *only* source for electronics parts and I would eagerly accompany my Father when he disposed of household rubbish. I would search thru all the Tip refuse looking for radios or television sets or anything with electronic components. Later in my early teens I made a hand trolley and on weekends would walk the 5 miles to the Tip towing the trolley, search for cast out electronics and head home with anything useful. I would then strip parts I thought useful, return the rest to my trolley where they would go back to the Tip on my next visit. I felt lucky to have this free resource nearby and who knew what may turn up there ? Over the years I found a CRT tube from a scope or radar set, a box full of Germanium transistors all of which were faulty and lots of valves, capacitors, resistors, transformers etc all salvaged from radios or tv's. I made a lot of gear using Tip parts and along the way I learnt how to design around what I had, to make what I wanted. In other words if the ARRl Handbook called for a 12AT7 valve and I only had a salvaged 12AU7, I'd have to design around that. Building equipment this way taught me a lot about design. Compared to buying the right gear from a Internet based vendor it was much harder and delayed all my projects as I experimented to try and make things work, but I learnt a lot even if I didn't realise it at the time. Every single project was a journey into the unknown with many failures and few hard won successes. We can learn as much from our failures as our successes. By the time I was fifteen years old I could walk into any business and get a job as a electronics technician the same day. All I had to do was take a project or two with me that demonstrated my design, chassis building, soldering, wiring and looming skills. I'm not exaggerating when I say some employers were actually stunned when they saw my work because the school of "ARRL Handbook" made such good students ;-) They Call it Stealing Now ^^^^^^^^^^^^^^^^^^^^^^^^^ At some point the *money hungry arseholes*, running the council Tips realised that they could make money selling rubbish so up went barbed wire fences, locked gates and warning signs and my free and open access plus the access of EVERY GENERATION OF KIDS after me was abruptly terminated. It still BUGS ME to see that kids nowadays have no access to rubbish tips like I had and that this opportunity is closed off forever for them. .. _the_hard_way: THE HARD WAY ------------ January 2020 Flowchart --------- .. image:: pics/sdcard-flowchart.jpg Which option below best describes your initial reaction to this flowchart ? 1. Awesome, so that's all I need to do to use a SD card ? 2. Ugh, can I have a library instead please ? 3. Honestly, I don't have the time to read this stuff 4. It's crap, I wrote a SD card library the other day in Forth check out *my* cool flowchart. If you answered 4. then you definitely don't need this site and I salute you. If you answered 1. welcome to this site I hope you find it interesting and helpful. Choices 2. and/or 3. mean this site isn't for you, don't waste another second with embedded electronics, leave immediately and good luck in some *other* area that does interest and motivate you. The Old ^^^^^^^ When I taught myself electronics I only had one book, the 1954 ARRL handbook, and various scrap electronics hardware I collected from the :ref:`local rubbish tip`. No one I knew had any electronics experience or interest and the only person who did, the local "radio and tv repair shop" was a one man band. As a result the guy was very busy and seemed annoyed when I tried to ask him electronics questions from the front counter of his shop in my local town, so after a couple of visits, with great disappointment, I realised that avenue was a dead end. Back in those days, around 1966 there were no home computers or Internet in Australia. Hobby electronics was relegated to Ham Radio as far as I know, and "Hams" built all their own gear. Amazingly I managed to survive and flourish using my own efforts which leads me to this rant. The New ^^^^^^^ I read this post online today : *Today, I posted my first (Stack Exchange) question trying to be very specific and described my troubleshooting efforts leading up to the post. It got a response about 2 minutes later claiming it was a duplicate and already answered in another thread. When I went to that thread, it was only slightly related and completely unhelpful - but my thread was now closed. Is this normal?* An experienced poster replied: *It is typical, unfortunately. There are a lot of "reputation" gamers, who post answers and close questions as duplicates even when they're not (and often also close questions because they themselves do not understand the question, especially when the question is hard). They do not really do it to help others, but to get more "reputation". The entire site is based on the idea that "best answers get voted to the top", but popularity and quality do not correlate much (and causate even less).* The Bad and The Worse ^^^^^^^^^^^^^^^^^^^^^ Today in 2020, it seems to me that the bulk of people learning electronics and programming naturally turn to the Internet. Sadly many Internet resources (apart from PDF component specs and manufacturer component data) are worse than useless. Worse Than Useless? ~~~~~~~~~~~~~~~~~~~ Bad information is worse than no information, and the Internet of 2020 is jam packed with *incorrect* information, *disinformation* and information *tainted* by vested interests such as the Stack Exchange example above and vendors casting doubts on reliability/safety of their competitions products. Internet learning in 2020 is a minefield and the question must be asked, is it a minefield worth the risk to cross ? Keep It Simple -------------- If you want to learn real embedded electronics, start with something simple and understand *every step* of the process by yourself and keep building, one step after another. In general (apart from datasheets), forget the Internet for learning Embedded Electronics, it's mainly a sales tool now, run by the best marketing types on Earth. Work it out yourself, you already have the most awesome resource available, the human brain! .. note:: simple doesn't mean easy, quick, or cheap. Asking For Help --------------- My philosophy is "never, ever ask until you have absolutely nothing left to try, until every avenue of investigation has been examined and you are totally exhausted and running on empty". Learning is like lifting weights, the harder it is, the better the results and the bigger ones *brain* muscle grows. A Learning Challenge -------------------- This is a simple $5 handmade Forth embedded computer, build one ? .. note:: Everything you need is on this site. Terminal view ^^^^^^^^^^^^^ .. image:: pics/prototyping/green-pill-terminal.jpg Schematic ^^^^^^^^^ .. image:: pics/prototyping/green-pill-schematic.jpg Construction ^^^^^^^^^^^^ .. image:: pics/prototyping/green-pill-usb3.3v-dongle.jpg .. image:: pics/prototyping/qfn32-header-board.jpg .. image:: pics/prototyping/qfn32-header-pcb-stm32f051-run-mode.jpg .. image:: pics/prototyping/qfn32-header-pcb-with-stm32f051-bottom-view.jpg .. _lackaday: Hackerspaces or SalesPlaces? ---------------------------- 25 Jan 2020 **A hackerspace is a community-operated, often "not for profit", workspace where people with common interests, such as computers, machining, technology, science, digital art, or electronic art, can meet, socialize and collaborate --Wikipedia** Hackaday.com ^^^^^^^^^^^^ https://hackaday.com/ is an online pseudo "hackerspace" business which describes itself like so: **Hackaday serves up Fresh Hacks Every Day from around the Internet. Our playful posts are the gold-standard in entertainment for engineers and engineering enthusiasts.** Personally I think Hackaday is more of a pewter standard than a gold one, because to me the Hackaday shine has lost its lustre and the thin gold plating wears off a little bit more every time they pretended an advertisement is an interesting article about technology. One thing that bugs me is that it seems Forth is *persona non grata* at Hackaday. * Hackaday last posted a Forth article exactly 12 months ago on January 25, 2019 titled "pocket-forth-invades-your-ti-calculator" https://hackaday.com/2019/01/25/pocket-forth-invades-your-ti-calculator/ * They last wrote about Mecrisp-Stellaris Forth in 2017, 3 years ago. * I submitted my :ref:`STM32F103C8 Diagnostics` project to Hackaday on Dec 17, 2019 and I've heard nothing from them. I think it's a useful project and *nothing* like it exists to the best of my knowledge. With this program, :ref:`Blue Pill` owners can determine if they have a bona fide STM32F103 chip or a counterfeit chip and whether it has a hidden extra 64kB of flash memory. Given there are millions of :ref:`Blue Pill` units in circulation, I think this is worthy of publication ? The :ref:`free binary` has been downloaded about twice a day in the last month, mainly by Windows users in the USA. No Forth knowledge is required and it's operated from a simple menu. .. image:: pics/stm32f103c8-diags.jpg Counterfeit Chips ~~~~~~~~~~~~~~~~~ This is one reason why the :ref:`STM32F103C8 Diagnostics` project is useful, helping to detect FAKE chips. .. image:: pics/counterfeitstm.jpg A real Beauty? ~~~~~~~~~~~~~~ On January 21, 2020 Hackaday published a article titled "CircuitPython Slithers Into 100th Board — The OHS 2020 Badge". This article builds up the hype about this 'cool' *badge*, remarking that **you can't actually buy one** because the badge won’t be for sale, but if you purchase an admission to the *OSHW Summit 2020* ($30 – $190) "you will be handed one of these beauties". Beauty is in the Eye of the Beholder ************************************ "Circuit Python" is a project by AdaFruit, it only runs on expensive, complex, vastly capable MCU's such as Cortex-M4 with a minimum 256kB flash and plenty of Ram. Overall it's about 30x slower than Forth on the same MCU, except Forth will run nicely on a cheap, highly capable Cortex-M0 class MCU with 32kB Flash and 4kB Ram, which Circuit Python will **never be able to do**. Hackaday reader "Cyk" comments: I stopped using Circuitpython when I needed interrupts and timers, and had to learn that Circuitpython simply doesn’t have them. So yeah, maybe a decent learner’s toy, but as so often a dead end, as soon as you advance. Cyk could do far more with a $2 :ref:`Blue Pill` than the crippled Circuit Python powered 'OHS 2020 Badge' Today's Gold Standards ---------------------- Todays gold-standard in entertainment for engineers and engineering enthusiasts at Hackaday include the following: 1. A Raspberry Pi Terminal That’s Always Within Reach 2. Students Use Low Tech Hacks On High Tech Parking Enforcer 3. Pi 4 Emulator In A Durable, Dumpstered Cabinet 4. A Simple Science Fair AM Transmitter 5. A Pair Of CRTs Drive This Virtual Reality Headset 6. BinDayCator Lets You Know When To Take Out The Trash 7. Spring Clamp Is Completely 3D Printed 5. looks interesting, the rest not so much. Perhaps Hackaday haven't published my :ref:`STM32F103C8 Diagnostics` project because they're still trying to work out how to do it with the :ref:`C programming language` now they are aware of the idea ;-) This isn't the only submission that silently vanished into the Hackaday *black hole*. Tethered Forth -------------- Nov 6, 2018 I emailed Hackaday about a brilliant Tethered Forth system Matthias has created, named *Mecrisp-Across*. I was so impressed I created a separate documentation site for it at https://mecrisp-across-folkdoc.sourceforge.io/ Apart from a reply email informing me the reviewer was travelling and would get back to me, I never heard from Hackaday again. .. image:: pics/mecrisp-across-boards-wired-800.jpg Tethered Forths provide the compact binary generation of The C Language **PLUS** the interactivity of Forth, *all in the one system*. If that doesn't excite you, WTF are you doing here ? Is no one at Hackaday able to understand the implications of such a system, do they consider their readers too dumb to understand it, or is it just a "Forth doesn't sell" attitude ? You'll have to decide :)