The latest attack is the heaviest fighting in weeks as al-Shabab tries to overthrow the fragile Somali administration and push out some 5,000 peacekeepers.
Both sides have been accused of indiscriminate shelling.
"Soldiers from Uganda and Burundi soldiers are our enemy. They often massacre our people," said Sheikh Ali Mohamed Hussein, a leader of al-Shabab, which is linked to al-Qaeda and controls much of southern Somalia.
"We will not let them go unpunished, but will target them in Kampala and Bujumbura", the capitals of the two countries.
The AU denies firing into residential areas.
Barigye Bahoku, a spokesman for the AU peacekeeping force, blamed insurgents for shelling civilian areas under their control to make it appear that the AU is behind it.
But many Somalis doubt such assertions.
"What cannot be denied is that most of the fire comes from the bases of the African Union, and they hit and kill civilians in the rebel-controlled areas," Ahmed Abdulahi, a businessman in Mogadishu, said.
"People have eyes and ears, they know what is going on."