Microcontroller Random Number Generation via Flash Memory and Clock Seeds
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Low-cost microcontroller units without random number generators (RNGs) require a method to generate random numbers for various application scenarios without the need for additional components or replacing the units.
Innovation Solution
A method that reads and writes random numbers to flash memory using microcontroller unit-specific information such as GPIO port readings and clock differences between internal clocks, eliminating the need for an RNG module by utilizing these sources as seeds for random number generation.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If a random number generator (RNG) module is included in the microcontroller unit, then the ability to generate random numbers is improved, but the cost and device complexity increase
Solution Approach 1:
The patent extracts the random number generation functionality from a dedicated RNG module and implements it using existing microcontroller components (flash memory, GPIO ports, internal clocks). This eliminates the need for a separate RNG module while maintaining the random number generation capability, directly resolving the contradiction between functionality and device complexity.
Solution Approach 2:
The microcontroller unit uses its own existing components (flash memory for storage, GPIO ports for random information, internal clocks for timing) to generate random numbers, rather than requiring external or dedicated RNG hardware. The system serves its own random number generation needs using resources already present in the device.
2Device complexity
If flash memory is used to store random numbers, then the need for additional hardware is reduced, but the flash memory writing次数 (write operations) increase which may affect durability
Solution Approach 1:
The patent implements a memory management mechanism that tracks the number of write operations to each flash memory sector and performs wear-leveling by switching between different sectors. When one sector reaches its write limit, the system transitions to another sector, thereby distributing wear across multiple areas and extending the overall lifespan of the flash memory while maintaining continuous random number generation capability.
3Reliability
If random information from GPIO ports and clock differences is used as seeds, then the randomness quality is improved, but the complexity of the generation algorithm increases
Solution Approach 1:
The patent uses simple copying and combining operations to integrate multiple random information sources (GPIO port readings, clock cycle differences) into a seed value for the random number generation algorithm. Rather than implementing complex processing, the system collects raw random data from multiple sources and uses it directly or with minimal transformation, maintaining high randomness quality while keeping the algorithm relatively simple.
Data Source
AI summary
A method of generating a random number for a microcontroller unit, the microcontroller unit using the method, an apparatus including the microcontroller unit are provided. The method includes: reading, from a flash memory of the microcontroller unit, a random number generated the previous time the microcontroller unit was powered on, in response to the microcontroller unit being powered on; acquiring, random information of the microcontroller unit and using the random information as a seed of a random number generation algorithm to generate the random number in a case that the reading fails, and using, the read random number as the seed of the random number generation algorithm to generate the random number in case that the reading succeeds; and writing, the generated random number to the flash memory of the microcontroller unit.


