Posts Tagged ‘break mcu archive’

PostHeaderIcon ATmega162A: Two Serial Ports and What a Second One Implies

One serial port is a product talking to something. Two serial ports is a product standing between two things, and that changes what the firmware does: it stops being a controller and becomes a translator.

The distinction is visible in an image before a single function is understood, because two channels means two sets of registers, two interrupt vectors, and code that moves data from one to the other.

What the second port implies

Four product shapes, each recognisable:

Bridge. Bytes arrive on one channel and leave on the other, with little or no modification. The code is a loop and two buffers.

Protocol translator. Frames arrive in one format and leave in another. The code contains two parsers and a mapping between them, and the mapping is the design.

Device plus service port. The main channel talks to the application; the second is a maintenance interface that accepts commands. The command handler is the interesting part.

Redundancy. Two channels carrying the same traffic, for reliability. Rare, and visible because the code treats them identically.

Shape Code signature What to look for first
Bridge Copy loop between two data registers Buffer sizes
Translator Two parsers, one mapper The mapping table
Service port Command dispatcher The command list
Redundancy Identical handling paths Failover logic

Why the interrupt vectors give it away

Each channel has its own receive and transmit vectors. In the vector table, four entries pointing at closely-spaced handlers means two channels active, because the handlers are usually generated from the same template and land near each other.

That is a cheap signal. Counting vector targets and looking for pairs takes a minute and establishes the channel count before any disassembly.

Buffer sizes describe the traffic

A bridge needs buffers, and the buffer sizes are set by the traffic: a command channel needs a few bytes, a data channel needs more, and a protocol with long frames needs a lot.

The initialisation code sets pointers and lengths for each buffer. Those values are a specification of what the product expects to receive — which for a translator is the frame size of the protocol it speaks.

Where the property is settled

The lock byte and the fuse byte are read before the array, as always. On this family the JTAG interface is present, and a product that used it during development may leave the fuse in a state that removes four port pins from general use.

That matters here because a bridge needs pins for the second channel, and a design that disabled JTAG did so to free pins for exactly that purpose. The fuse byte and the architecture tell the same story from two directions.

Reading order

  1. Signature, fuses, lock byte.
  2. Array read, verified.
  3. Vector table: count channel pairs.
  4. Initialisation: buffer pointers and lengths per channel.
  5. The path between channels: copy loop, parser, or dispatcher.

Step 5 determines the product category, and it is usually reachable within the first few thousand instructions because translators tend to be small.

Related notes

FAQ

Are the two channels truly independent? Yes. Separate registers, separate vectors, separate baud rate generators.

Can both run at different baud rates? Yes, and the initialisation sets them separately.

Does a second port mean a second protocol? Usually, which is why translators exist.

Is JTAG relevant to the serial channels? Only through pin allocation: disabling it frees pins that a second channel may use.

Conclusion

A second serial channel changes the product category, and the change is visible in the vector table before anything else is read. Buffer sizes describe the traffic, and the code between the channels is the design. On a part built for bridging, that path is where the value is.

PostHeaderIcon ATmega261PA: Output Drivers, Slew, and Code That Depends on Them

Code is digital; pins are analogue. Between them sits an output driver with a finite rise time, a finite drive current, and a behaviour that changes when the die is redesigned. A picoPower revision redesigns those drivers, and firmware that assumed the old ones can fail without a single instruction differing.

This is the class of problem that is hardest to attribute, because the program is identical, the board is identical, and only the part changed.

What a picoPower revision alters at the pin

Three characteristics shift, all in the direction of lower power:

Drive current. The driver can source and sink less. A pin driving an LED directly sees a dimmer LED; a pin driving a capacitive load sees a slower edge.

Slew rate. Deliberately reduced on many pins, because fast edges waste current. A slower edge is fine for a static signal and not fine for a signal that has to meet a setup time.

Pull-up and pull-down strength. Weaker, for the same reason. A pin relying on an internal pull-up to charge a node now takes longer to do so.

None of these appears in the code. All of them can break it.

Where firmware depends on the driver

Four patterns, in order of frequency:

Bit-banged protocols with no delay. A two-wire or one-wire implementation that toggles a pin and immediately samples it depends on the pin settling within the instruction time. A weaker driver breaks it.

Multiplexed displays. Segments driven directly from port pins rely on sufficient current. Lower drive means dimmer output rather than a fault, which is easy to miss.

RC timing loops. A pin charging a capacitor until a threshold is reached takes longer with a weaker driver, which shifts every timing constant derived from it.

Shared buses without an external driver. A bus with more than a couple of devices and no buffer relies on the pin’s drive to meet timing.

Dependency Symptom after a revision change Diagnostic
Bit-banged bus Intermittent acknowledge failures Scope the edge
Direct LED drive Dimmer, not broken Measure current
RC timing Consistent offset in measurements Recompute the constant
Unbuffered bus Marginal at temperature extremes Look at rise time

Why this reads as a software bug

If a device works on the old die and fails on the new one, the natural hypothesis is a firmware change. Verification says the firmware is identical, which points at the hardware, and the hardware is the same board.

The remaining variable is the die, and the mechanism above is what changes on it. That reasoning is easy to follow once stated and hard to reach from symptoms, because the symptom is a protocol failure and the cause is a drive current.

What the code reveals

The dependency is visible in the code, if you know to look:

  • A toggle followed immediately by a sample, with no delay between, is a timing dependency on the driver.
  • A port write driving a load with no transistor in the schematic is a current dependency.
  • A loop counting until an input changes is an RC dependency.

Each of those is a design decision that was validated on one die. Recording it makes the risk explicit, which is the useful outcome: not “this is broken” but “this depends on a pin characteristic that revisions can change”.

Reading order

  1. Signature and fuses, including the package date code, because the die is the variable.
  2. Lock byte.
  3. Array read, verified.
  4. Port initialisation: which pins are outputs, which have pull-ups.
  5. Cross-reference every output pin against the external circuit.

Step 5 is the one that turns the image into a risk assessment. A pin that drives a transistor is robust; a pin that drives a node directly is not.

Related notes

FAQ

Does a picoPower part drive less current? Generally yes, and the datasheet gives the figures per pin and per supply.

Can the drive be increased in software? Not on this family. The characteristic is set by the die.

Why does a bit-banged bus fail intermittently? Because the edge is slower and the sampling point is now marginal rather than comfortable.

Is a dimmer LED a fault? It is a consequence. Whether it matters depends on the specification the product has to meet.

Conclusion

Pin behaviour is part of the contract between firmware and hardware, and revisions can change it without changing a single instruction. Reading the port configuration and asking what each output actually drives converts an unexplained field failure into a stated dependency — which is the only form in which it can be managed.

PostHeaderIcon Break MCU ATmega2560L Flash

Break MCU ATmega2560L Flash memory and crack microcontroller atmega2560L fuse bit, read embedded heximal code out from MCU ATmega2560L flash memory;

Break MCU ATmega2560L Flash memory and crack microcontroller atmega2560L fuse bit, read embedded heximal code out from MCU ATmega2560L flash memory
Break MCU ATmega2560L Flash memory and crack microcontroller atmega2560L fuse bit, read embedded heximal code out from MCU ATmega2560L flash memory

The Timer/Counter can be clocked by an internal synchronous or an external asynchronous clock source. The clock source clkT2 is by default equal to the MCU clock, clkI/O.

When the AS2 bit in the ASSR Register is written to logic one, the clock source is taken from the Timer/Counter Oscillator connected to TOSC1 and TOSC2. For details on asynchronous operation, see “Asynchronous Status Register – ASSR” on page 189 if recover pic16c554 MCU software.

For details on clock sources and prescaler, see “Timer/Counter Prescaler” on page 193. The main part of the 8-bit Timer/Counter is the programmable bi-directional counter unit.

Figure 68 shows a block diagram of the counter and its surrounding environment. Depending on the mode of operation used, the counter is cleared, incremented, or decremented at each timer clock (clkT2). clkT2 can be generated from an external or internal clock source, selected by the Clock Select bits (CS22:0) before recover pic16f83 Mcu flash.

When no clock source is selected (CS22:0 = 0) the timer is stopped. However, the TCNT2 value can be accessed by the CPU, regardless of whether clkT2 is present or not. A CPU write overrides (has priority over) all counter clear or count operations.

The counting sequence is determined by the setting of the WGM21 and WGM20 bits located in the Timer/Counter Control Register (TCCR2A) and the WGM22 located in the Timer/Counter Control Register B (TCCR2B).

There are close connections between how the counter behaves (counts) and how waveforms are generated on the Output Compare outputs OC2A and OC2B. For more details about advanced counting sequences and waveform generation, see “Modes of Operation” on page 178.

The Timer/Counter Overflow Flag (TOV2) is set according to the mode of operation selected by the WGM22:0 bits. TOV2 can be used for generating a CPU interrupt.

The 8-bit comparator continuously compares TCNT2 with the Output Compare Register (OCR2A and OCR2B). Whenever TCNT2 equals OCR2A or OCR2B, the comparator signals a match. A match will set the Output Compare Flag (OCF2A or OCF2B) at the next timer clock cycle.

If the corresponding interrupt is enabled, the Output Compare Flag generates an Output Compare interrupt. The Output Compare Flag is automatically cleared when the interrupt is executed.

Alternatively, the Output Compare Flag can be cleared by software by writing a logical one to its I/O bit location. The Waveform Generator uses the match signal to generate an output according to operating mode set by the WGM22:0 bits and Compare Output mode (COM2x1:0) bits. The max and bottom signals are used by the Waveform Generator for handling the special cases of the extreme values in some modes of operation (“Modes of Operation” on page 178). Figure 58 on page 154 shows a block diagram of the Output Compare unit.

PostHeaderIcon Break MCU PIC16F628A Program

Break MCU PIC16F628A Program is a process to attack microchip microcontroller pic16f628a security fuse bit by focus ion beam and then copy embedded heximal from pic16f628a flash memory;

Break MCU PIC16F628A Program is a process to attack microchip microcontroller pic16f628a security fuse bit by focus ion beam and then copy embedded heximal from pic16f628a flash memory
Break MCU PIC16F628A Program is a process to attack microchip microcontroller pic16f628a security fuse bit by focus ion beam and then copy embedded heximal from pic16f628a flash memory

ICFn is automatically cleared when the Input Capture Interrupt Vector is executed. Alternatively, ICFn can be cleared by writing a logic one to its bit location.

Bit 3– OCFnC: Timer/Countern, Output Compare C Match Flag

This flag is set in the timer clock cycle after the counter (TCNTn) value matches the Output Compare Register C (OCRnC).

Note that a Forced Output Compare (FOCnC) strobe will not set the OCFnC Flag. OCFnC is automatically cleared when the Output Compare Match C Interrupt Vector is executed. Alternatively, OCFnC can be cleared by writing a logic one to its bit location.

Bit 2 – OCFnB: Timer/Counter1, Output Compare B Match Flag

This flag is set in the timer clock cycle after the counter (TCNTn) value matches the Output Compare Register B (OCRnB).

Note that a Forced Output Compare (FOCnB) strobe will not set the OCFnB Flag. OCFnB is automatically cleared when the Output Compare Match B Interrupt Vector is executed. Alternatively, OCFnB can be cleared by writing a logic one to its bit location if Break microcontroller pic16f628a memory.

Bit 1 – OCF1A: Timer/Counter1, Output Compare A Match Flag

This flag is set in the timer clock cycle after the counter (TCNTn value matches the Output Compare Register A (OCRnA).

Note that a Forced Output Compare (FOCnA) strobe will not set the OCFnA Flag. OCFnA is automatically cleared when the Output Compare Match A Interrupt Vector is executed. Alternatively, OCFnA can be cleared by writing a logic one to its bit location.

Bit 0 – TOVn: Timer/Countern, Overflow Flag

The setting of this flag is dependent of the WGMn3:0 bits setting. In Normal and CTC modes, the TOVn Flag is set when the timer overflows. Refer to Table 82 on page 160 for the TOVn Flag behavior when using another WGMn3:0 bit setting if attacking pic16f711 MCU memory.

TOVn is automatically cleared when the Timer/Countern Overflow Interrupt Vector is executed. Alternatively, TOVn can be cleared by writing a logic one to its bit location.